﻿(function(ns, pt, Fw_map){
	var _win = window;
	var _doc = document;
	
	//命名空间、唯一全局对象、构造器
	var F = _win.$1stjs = function(v){
		if(F.isfdom(v)){
			return v;
		}
		var node = F.node(arguments.length>0?v:_doc.body);
		if(node){
			var Class = function(){
				this.isfdom = true;
				this.node = node;
				this.tag = this.node==_win ? "win" : this.node==_doc ? "doc" : this.node.tagName.toLowerCase();
			};
			Class.prototype = _Fwdom;
			var instance = new Class();
			instance.toString = function(){return "Fdom"};
			return instance;
		}
		return false;
	};


	/*====================================一、Fw核心*=================================================*/

	/*--------------1.框架特性----------------*/
	
	//版权信息
	F.about = {
		author : "likaituan",
		email : "61114579@qq.com",
		version : "4.0",
		date : "2010-09-05",
		lastime : "2011-8-18"
	};
	
	//单例对象转化为类实例
	F.Class = function(o) {
		var Class = function(){};
		Class.prototype = o;
		return function(){
			var instance = new Class();
			instance.init && instance.init.apply(instance,arguments);
			return instance;
		};
	};
	
	//单例对象转化为函数
	F.Fun = function(o){
		var Class = function(){};
		Class.prototype = o;
		return function(){
			var instance = new Class();
			return instance.init.apply(instance,arguments);
		};
	};
	
	//显示JSON字符串
	F.alert = function(){
		var msg = [];
		for(var i=0,a=arguments,l=a.length; i<l; i++){
			msg[i] = F.json_stringify(a[i]);
		}
		msg = msg.join(",");
		alert(msg);
		return msg;
	};
	
	//本地数据
	F.data = function(url){
		return F.path + "data/" + (url||"");
	}
	
	//加载完成回调
	F.ready = function(o){
		if(F.isfun(o)){
			return _ready(o);
		}
		o.init && _ready(F.proxy(o,o.init));
		return o;
	}

	//加载完成回调
	var _ready = function(){
		var isReady=false, 
		readyList= [],
		timer,
		ready=function(fn) {
			if (isReady){
				fn();
			}else{
				readyList.push(fn);
			}
		},
		onDOMReady=function(){
			for(var i=0,lg=readyList.length;i<lg;i++){
				readyList[i]();
			}
			readyList = null;
		},
		bindReady = function(evt){
			if(isReady)return;
			isReady=true;
			onDOMReady();
			if(_doc.removeEventListener){
				_doc.removeEventListener("DOMContentLoaded",bindReady,false);
			}else if(_doc.attachEvent){
				_doc.detachEvent("onreadystatechange", bindReady);
				if(_win == _win.top){
					clearInterval(timer);
					timer = null;
				}
			}
		};
		if(_doc.addEventListener){
			_doc.addEventListener("DOMContentLoaded", bindReady, false);
		}else if(_doc.attachEvent){
			_doc.attachEvent("onreadystatechange", function(){
				if((/loaded|complete/).test(_doc.readyState))bindReady();
			});
			if(_win == _win.top){
				timer = setInterval(function(){
					try{
						isReady||_doc.docElement.doScroll('left');
					}catch(e){
						return;
					}
					bindReady();
				},5);
			}
		}
		return ready;
	}();
	
	/*--------------2.浏览器相关----------------*/
	
	//获取操作系统信息
	F.os = (/window|linux/i.exec(navigator.userAgent)||["unknown"])[0].toLowerCase();
	
	//获取浏览器信息
	F.browser = (/(msie|firefox|chrome|safari|opera)\D*(\d+(?:\.\d+)*)/.exec(navigator.userAgent.toLowerCase())||[0,"unknown",0]).slice(1);
	F.isie = F.browser[0]=="msie";
	F.isie6 = F.isie && F.browser[1].charAt(0)==6;
	F.iscanvas = !!_doc.createElement("canvas").getContext;
	
	//获取浏览器显示区域大小
	F.dw = _doc.documentElement.clientWidth;
	F.dh = _doc.documentElement.clientHeight;
	
	//cook操作
	F.cookie = function(key, val, t){
		if(arguments.length==1){
			var arr = _doc.cookie.match(new RegExp("(^| )"+ key +"=([^;]*)(;|$)"));
			if(arr != null) return unescape(arr[2]);
			return null;
		}
		var exp  = new Date();
		exp.setTime(exp.getTime() + (t||24)*60*60*1000);
		_doc.cookie = key + "="+ escape(val) + ";expires=" + exp.toGMTString()+';path=/';
		return this;
	};
	
	//复制
	F.copy = function(copytext){
		var obj;
		if(F.isobj(copytext)){
			obj = copytext;
			copytext = obj.value;
		}
		if(_win.clipboardData){
			_win.clipboardData.clearData();
			_win.clipboardData.setData("Text",copytext);
		}else if(F.browser[0]=="opera"){
			_win.location = copytext;
		}else if(_win.netscape){
			try{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}catch(e){
				alert("您的firefox安全限制限制您进行剪贴板操作，请打开’about:config’将signed.applets.codebase_principal_support’设置为true’之后重试，相对路径为firefox根目录/greprefs/all.js\n\n如果不设置，你也可以手动复制，谢谢！");
				obj && obj.select();
				return false;
			}
			var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
			var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
			if(!clip||!trans){
				return false;	
			}			
			var clipid = Components.interfaces.nsIClipboard;
			var o = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);			
			o.data = copytext;		
			trans.addDataFlavor('text/unicode');
			trans.setTransferData("text/unicode", o, copytext.length*2);
			clip.setData(trans,null,clipid.kGlobalClipboard);
		}else{
			alert("您的浏览器不支持复制功能，请手动复制，谢谢！");
			obj && obj.select();
			return false;
		}
		alert("生成的代码已经复制到粘贴板，你可以使用Ctrl+V 贴到需要的地方去了哦！  ");
		return F;
	}
	
	//读取本地文件
	F.read = function(fileObj, funName){
		var iframe = F("iframe1st").size(800,600);
		var form = fileObj.form;
		//form.enctype = "mutlipart/form-data";
		//form.method = "POST";
		form.action = "../data/data.php?act=readFile&fileName="+fileObj.name+"&funName="+funName;
		alert(form.action);
		form.target = "iframe1st";
		form.submit();
		return this;
	}
	
	//保存文件
	F.save = function(codeText, fileName){
		if(F.isnode(codeText)){
			codeText = codeText.value;
		}
		var win = window.open("", "_blank", "top=-2000");
		var doc = win.document;
		doc.open("text/html", "replace");
		doc.writeln(codeText);
		doc.execCommand("saveas", "", fileName||"test.html");
		win.close();
		return true;
	}
	
	/*--------------3.常用正则表达式----------------*/

	//正则匹配
	F.re = {
		en:/^[a-z]+$/i,											//匹配英文
		cn:/^[\u4e00-\u9fa5]+$/,								//匹配中文
		num:/^\-?\d+(?:\.\d+)?$/,								//匹配数字（包括小数点）		
		int:/^\-?\d+$/,											//匹配整数
		sint:/^(0|[1-9]\d*)$/,									//匹配正整数		
		pint:/^\d+$/,											//匹配纯数字
		uid:/^[a-z][a-z0-9_]*$/i,								//匹配登陆账号(字母开头，接数字、字母、下划线)		
		zipcode:/^[1-9]\d{5}$/,									//匹配邮编(6位，首位不为零）
		qq:/^[1-9][0-9]{4,9}$/,									//匹配QQ号（5到10位，首位不为零）
		email:/^[\w\-]+(\.[\w\-]+)?@[\w\-]+(\.[\w\-]+){1,3}$/,	//匹配电子邮箱,比如:61114579@qq.com或li.kaituan@vip.qq.com等
		url:/^http:\/\/[\w-]+(\.[\w-]+)+\/?.*$/i,				//匹配网址
		mobile:/^(13|15|18)\d\-?\d{8}$/,						//匹配手机号码13/15/18开头的前3位+后8位，之间可加杠
		tel:/^\d{3,4}\-?\d{7,8}(\-\d{1,5})?$/,					//匹配固定电话号码，限国内，前3到4位+后7到8位，之间可加杠,分机号前必须加杠，最多5位
		phone:/^(13|15|18)\d\-?\d{8}$|^\d{3,4}\-?\d{7,8}(\-\d{1,5})?$/,	//电话，手机和固定电话之一	
		ip:/^(([01]?[\d]{1,2})|(2[0-4][\d])|(25[0-5]))(\.(([01]?[\d]{1,2})|(2[0-4][\d])|(25[0-5]))){3}$/,	//IP地址
		//idcard:/^\d{15}$|^\d{17}(?:\d|X)$/,					//匹配身份证（15或18位）		
		car:/^[\u4e00-\u9fa5][A-Z][A-Z0-9]{5}$/,				//匹配车牌
		bir:/^(19|20)\d\d(0[1-9]|1[0-2])([012][1-9]|3[01])$/	//匹配8位数的生日，1900-2099年间
	};
	
	/*--------------4.类型判断----------------*/
	
	//判断数据是否为对象，不包括null
	F.isobj = function(v, flag){
		var isobj = typeof(v)=="object" && v!=null;
		//判断是否空对象
		if(isobj && F.isset(flag)){
			for(var name in obj){
				return !!flag;
			}
		}
		return isobj;
	}
	
	//判断数据是否为数组|函数
	F.isarr = function(v){
		return F.isobj(v) && (v instanceof Array);
	};
	
	//判断数据是否为数组|函数
	F.isfun = function(v){
		return typeof(v)=="function"  && (v instanceof Function);
	};	
	
	//判断数据是否为字符串|数字
	F.isstr = function(v){
		return typeof(v)=="string";
	};
	
	//判断数据是否为字符串|数字
	F.isnum = function(v){
		return typeof(v)=="number";
	};
	
	//是否存在
	F.isset = function(v){
		return v!==undefined;
	}
	
	//是否不存在
	F.unset = function(v){
		return v===undefined;
	}
	
	//判断数据是否为节点对象
	F.isnode = function(v){
		return F.isobj(v) && v.nodeType===1 && !!v.nodeName;
	};
	
	//判断变量是否为DOM对象
	F.isdom = function(v){
		return F.isnode(v)||v==_win||v==_doc;
	};
	
	//判断数据是否为Fdom对象
	F.isfdom = function(v){
		return F.isobj(v) && v.isfdom===true;
	};
	
	
	//判断数据是否为Fdoms对象
	F.isfdoms = function(v){
		return F.isobj(v) && v.isfdoms===true;
	};
	
	//判断数据是否为非空集合
	F.iscollect = function(v){
		return F.isobj(v) && F.isset(v.length);
	};
	
	//判断数据是否为非空集合
	F.isdoms = function(v){
		return F.isobj(v) && F.isset(v.length) && v.length>0 && F.isnode(v[0]);
	};
	
	/*--------------5.类型强制转换----------------*/
	
	//强制转换为日期
	F.date = function(d){
		return F.isstr(d) ? new Date(d.replace(/\-/g,"/")) : d;
	};
	
	//lambda表达式函数
	F.lambda = function(fn){
		return F.isstr(fn) ? new Function("a","b","c","return "+fn) : fn;
	};
	
	/*--------------6.数据格式转换----------------*/
	
	//秒转换为毫秒
	F.s2ms = function (str){
		var t = str.split(":");
		return t[0] * 60000 + t[1] * 1000;
	};
	
	//毫秒转换为秒
	F.ms2s = function (ms){
		return (ms/60000+":"+ms/1000%60).replace(/\.\d+/g,"").replace(/(^|:)(\d)(?!\d)/g,"$10$2");
	};
	
	//数字转化为中文
	F.num2gb = function (n){
		return "零一二三四五六七八九".split("")[n];
	};
	
	//中文转化为数字
	F.gb2num = function (gb){
		return "零一二三四五六七八九".indexOf(gb);
	};
	
	//RGB颜色转化为16进制的颜色值
	F.rgb2hex = function (r,g,b){
		return "#" + F.zero(r.toString(16)) + F.zero(g.toString(16)) + F.zero(b.toString(16));
	};
	
	//GB转化为字节
	F.gb2byte = function (gb){
		return gb*1024*1024*1024;
	};
	
	//字节转化为GB
	F.byte2gb = function (byte){
		//return num<1<<10 ? num+" B" : (num<1<<20 ? (num/(1<<10)).toFixed(2)+" KB" : (num/(1<<20)).toFixed(2)+" MB")
		return byte/1024/1024/1024;
	};


	/*====================================二、DOM操作=================================================*/

	var _Fwdom = {
		/*--------------2.查找----------------*/
		
		//获取父节点
		parent : function (level){
			level = level || 1;
			var obj = this.node;		
			for(var i=0; i<level; i++){
				obj = obj.parentNode;
			}
			return F(obj);
		},
		
		//获取兄弟节点
		sibling : function (idx){			
			//相对与本节点的
			if(F.isset(idx) && F.re.num.test(idx)){
				var dir = idx>0 ? "nextSibling" : "previousSibling";
				idx = Math.abs(idx);
				var obj = this.node;
				while(obj=obj[dir]){
					if(obj.nodeType==1&&(--idx==0)){
						return F(obj);
					}
				}
				return false;
			}

			//获取兄弟节点列表	
			var a = [];
			(F.unset(idx)?"<>":idx).replace(/./g,F.proxy(this,function(dir){
				var obj = this.node;
				if(dir=="<"){
					while(obj=obj.previousSibling){
						obj.nodeType==1 && a.unshift(obj);
					}					
				}else if(dir==">"){
					while(obj=obj.nextSibling){
						obj.nodeType==1 && a.push(obj);
					}					
				}
			}));
			return F.doms(a);
		},

		//上一个节点
		prev : function(){
			return this.sibling(-1);
		},
		
		//下一个节点
		next : function(){
			return this.sibling(1);
		},
		
		//获取子节点
		child : function (idx){
			//获取子节点集合
			if(arguments.length==0){
				var ol = [];	
				for (var nodes=this.node.childNodes,l=nodes.length,i=0; i<l; i++){
					nodes[i].nodeType==1 && ol.push(nodes[i]);
				}
				return F.doms(ol);
			}
			
			//获取子节点
			var getChild = function(obj, a){
				var nodes = obj.childNodes;
				var l = nodes.length;
				var idx = +a.shift();
				var i;
				if(idx<0){
					for(i=l-1; i>=0; i--){
						if(nodes[i].nodeType==1&&++idx==0) break;
					}
				}else{
					for(i=0; i<l; i++){
						if(nodes[i].nodeType==1&&--idx<0) break;
					}
				}
				if(i<0||i>=l){
					return false;
					//throw "child("+i+") is out range";
				}				
				return a.length>0 ? getChild(nodes[i],a) : F(nodes[i]);
			}
			return F(getChild(this.node, F.map(arguments)));
		},
		
		//第一个节点
		first : function(){
			return this.child(0);
		},
		
		//最后一个节点
		last : function(){
			return this.child(-1);
		},
		
		//标签选择器
		tags : function (exp){
			var a=[], doms, k, v, fun;
			if(/^\w+$/.test(exp)){
				a = this.node.getElementsByTagName(exp);
			}else if(/^(\w+)\.(\w+)$/.test(exp)){
				doms = this.node.getElementsByTagName(RegExp.$1);
				for(var i=0,l=doms.length; i<l; i++){
					doms[i].className==RegExp.$2 && a.push(doms[i]);
				}
			}else if(/^(\w+)\[(\w+)((!)?=(.+))?\]$/.test(exp)){
				doms = this.node.getElementsByTagName(RegExp.$1);
				k = RegExp.$2;
				if(RegExp.$3){
					v = RegExp.$5;					
					fun = RegExp.$4=="!" ? F.lambda("a!=b") : F.lambda("a==b");
					for(var i=0,l=doms.length; i<l; i++){
						fun(doms[i][k]||doms[i].getAttribute(k),v) && a.push(doms[i]);
					}
				}else{
					for(var i=0,l=doms.length; i<l; i++){
						doms[i].node.hasAttribute(k) && a.push(doms[i]);
					}
				}
			}			
			return F.doms(a);
		},
		
		//获取索引值
		index : function(idx){
			var i = 0;
			var obj = this.node;
			while(obj=obj.previousSibling){
				obj.nodeType==1 && ++i;
			}
			return idx===undefined ? i : idx==i;
		},

			
		/*--------------3.操作----------------*/
		
		//增加节点
		append : function (tag, idx){
			var obj;
			if(/^(\w+)(\.(\w+))?$/.test(tag)){
				obj = _doc.createElement(RegExp.$1);
				RegExp.$2 && (obj.className=RegExp.$3);
			}else{
				var div = _doc.createElement("div");
				div.innerHTML = tag;
				obj = div.firstChild;
			}
			if(F.unset(idx)){
				this.node.appendChild(obj);
			}else{
				this.node.insertBefore(obj, F.isstr(idx) ? this.node.childNodes[idx] : this.child(idx).node);
			}
			return F(obj);
		},
		
		//追加节点并铺满父元素
		full : function(tag){
			return this.append(tag||"div").css("left:0;top:0;width:100%;height:100%");
		},
		
		//删除当前节点
		remove : function (){
			this.parent().node.removeChild(this.node);
			return this;
		},
		
		//清空子节点,$type==2时，删除非元素节点,只保留元素节点
		empty : function (typeid){
			if(F.unset(typeid)){
				while(this.node.firstChild){
					this.node.removeChild(this.node.firstChild);
				}
			}else{
				for (var nodes=this.node.childNodes,i=nodes.length-1; i>=0; i--){
					nodes[i].nodeType!=typeid && this.node.removeChild(nodes[i]);
				}
			}
			return this;
		},
		
		/*--------------4.样式-----------------*/
		
		//1.基本样式
		
		//CSS样式
		css : function(p, v){
			//name/value格式
			if(F.isobj(p)){
				for(var i in p){
					this.css(i,p[i]);
				}
				return this;
			}
			//CSS多样式格式
			if(p.indexOf(":")>-1){
				F.each(p.replace(/;$/,"").split(";"), F.proxy(function(s){
					var a = s.split(":");
					this.css(F.trim(a.shift()), F.trim(a.join(":")));
				},this));
				return this;
			}
			//横杠小写字母替换为大写
			if(/\-\w/.test(p)){
				p = p.replace(/\-(\w)/, function(s,s1){return s1.toUpperCase();});
			}			
			//获取单项属性
			if(arguments.length==1){
				return this.node.style[p] || (
				_doc.defaultView ? _doc.defaultView.getComputedStyle(this.node, null)[p] : 
				this.node.currentStyle ? this.node.currentStyle[p] : "");
			}
			//设置单项属性
			var aa=2;
			this.node.style[p] = v;
			return this;
		},
		
		//获取节点px值
		px : function(name, val){
			if(arguments.length==2){
				this.node.style[name] = val + "px";
				return this;
			}
			return parseInt(this.css(name),10) || 0;
		},
		
		//className
		cls : function(v){
			//v可能为空
			if(F.isset(v)){
				if(v.indexOf(".")==-1){
					this.node.className = v;
					return this;
				}
				v = this.node.getElementsByClassName(v.slice(1));
				return F(v[0]) || false;
			}
			return this.node.className;
		},
		
		//设置浮动
		float : function(dir){
			return this.css(this.node.style.styleFloat?"styleFloat":"cssFloat", dir||"left");
		},
		
		//设置绝对定位
		ps : function(){
			return this.css("position","absolute");
		},
		
		//设置透明度
		opacity : function(n){
			if(arguments.length==1){
				if(this.node.style.opacity!=undefined){
					return this.css("opacity", n);
				}
				return this.css("filter", "alpha(opacity="+n*100+")");
			}
			if(this.node.style.opacity!=undefined){
				return F.re.num.test(this.css("opacity")) ? +RegExp.lastMatch : 1;
			}
			return /alpha\(opacity=(\d+)\)/.test(this.css("filter")) ? RegExp.$1/100 : 1;
		},
		
		//设置对齐方式
		align : function(align_method){
			return this.css("text-align", align_method);
		},
		
		//设置边框样式
		border : function(){
			var o = {px:1, st:"solid", color:"#00f"};
			F.map(arguments).join(" ").replace(/\S+/g, function(s){
				s.replace(/^(\d+)(?:px)?$|^(solid|dashed)$|.+/,function(s,a,b){o[a?"px":b?"st":"color"]=s});
			});
			return this.css("border", F.mix("$px$px $st $color",o));
		},
		
		//设置鼠标样式
		cursor : function(v){
			return this.css("cursor", v||"pointer");
		},
		
		//2.位置大小
		
		//设置或获取左上角X坐标的值
		left : function(x){
			if(arguments.length==1){
				return this.px("left",x);	
			}
			return this.px("left") || this.node.offsetLeft-this.px("marginLeft");
		},
		
		//设置或获取左上角Y坐标的值
		top : function(y){
			if(arguments.length==1){
				return this.px("top",y);
			}
			return this.px("top") || this.node.offsetTop-this.px("marginTop");
		},

		//设置或获取宽度值
		width : function(w){
			if(arguments.length==1){
				return this.px("width",w);	
			}
			return this.px("width") ||
			this.node.offsetWidth-this.px("paddingLeft")-this.px("paddingRight")-this.px("borderLeftWidth")-this.px("borderRightWidth");		
		},	
		
		//设置或获取高度值
		height : function(h){
			if(arguments.length==1){
				return this.px("height", h);
			}
			return this.px("height") ||
			this.node.offsetHeight-this.px("paddingTop")-this.px("paddingBottom")-this.px("borderTopWidth")-this.px("borderBottomWidth");
		},

		//设置或获取元素的位置
		pos : function(x,y){
			var n = arguments.length;
			if(n==2){
				return this.left(x).top(y);				
			}else if(n==0){
				return [this.left(), this.top()];
			}else if(n==1){
				return {x:this.left(), y:this.top()};
			}
		},
		
		//设置或获取元素的尺寸大小
		size : function(w,h){
			var n = arguments.length;
			if(n==2){
				return this.width(w).height(h);	
			}else if(n==0){
				return [this.width(), this.height()];
			}else if(n==1){
				return {w:this.width(), h:this.height()};
			}
		},
		
		//设置或获取元素的位置和大小
		rect : function(x,y,w,h){
			var n = arguments.length;
			if(n==4){
				return this.pos(x,y).size(w,h);
			}else if(n==0){
				return [this.left(), this.top(), this.width(), this.height()];
			}else if(n==1){
				return {x:this.left(), y:this.top(), w:this.width(), h:this.height()};
			}
		},
		
		//偏移(对齐、重叠)
		offset : function(targetObj, mode, offsetX, offsetY, offsetW, offsetH){
			var fo = F(targetObj);			
			mode = mode || "rect";
			offsetX = offsetX || 0;
			offsetY = offsetY || 0;			
			offsetW = offsetW || 0;
			offsetH = offsetH || 0;			
			if(mode=="rect"){
				return this.rect(fo.left()+offsetX, fo.top()+offsetY, fo.width()+offsetW, fo.height()+offsetH);
			}else if(mode=="pos"){
				return this.pos(fo.left()+offsetX, fo.top()+offsetY);
			}else if(mode=="size"){
				return this.size(fo.width()+offsetW, fo.height()+offsetH);
			}
		},
		
		//移到正中央
		center : function(){
			var o1 = this.parent().size(1);
			var o2 = this.size(1);
			return this.pos(Math.floor(o1.w/2-o2.w/2), Math.floor(o1.h/2-o2.h/2));
		},	
		
		//移出页面之外
		out : function(){
			return this.top(-999);
		},
		
		//获取中心点
		midpoint : function(flag){
			var o = {
				x : Math.floor(this.left()+this.width()/2),
				y : Math.floor(this.top()+this.height()/2)
			};
			return flag ? o : [o.x,o.y];
		},
		
		//获取元素在页面中的绝对位置
		abspos : function (flag){
			var o = {x:0,y:0};
			for(var obj=this.node; obj; obj=obj.offsetParent){
				o.x += obj.offsetLeft;
				o.y += obj.offsetTop;
			}
			return flag==1 ? o : [o.x,o.y];
		},
		
		//按比例缩放到
		scaleTo : function (width, height){
			return this;
		},
		
		//scrollLeft
		scrollLeft : function (px){
			if(F.isset(px)){
				this.node.scrollLeft = px;
				return this;
			}
			return this.node.scrollLeft;
		},
		
		//scrollTop
		scrollTop : function (px){
			if(F.isset(px)){
				this.node.scrollTop = px;
				return this;
			}
			return this.node.scrollTop;			
		},		
		
		//3.显示隐藏

		//显示
		show : function(){
			return this.css("display", /^(span|img|a|input|b|u|i|label|strong|em)$/.test(this.tag)===false?"block":"inline");
		},
		//隐藏
		hide : function(){
			return this.css("display", "none");
		},
		//切换元素的可见状态
		toggle : function(){
			this.css("display")=="none" ? this.show.apply(this,arguments) : this.hide();
			return this.css("display");
		},

		//4.背景
		
		//背景颜色
		bg : function(color){
			if(arguments.length==0){
				return this.css("backgroundColor");
			}
			return this.css("backgroundColor", color);
		},
		//背景图片
		bgimg : function(img){
			if(arguments.length==0){
				return this.css("backgroundImage").replace(/url\([\"\']?(.+?)[\"\']?\)/i, "$1");
			}
			if(img!="none"){
				img = "url("+img+")";
			}
			return this.css("backgroundImage", img);
		},	
		//背景位置
		bgpos : function(x, y){
			if(arguments.length<1){
				return this.css("backgroundPosition");
			}
			y = y || 0;
			return this.css("backgroundPosition", x+"px "+y+"px");
		},

		/*--------------5.属性-----------------*/
		
		//innerHTML
		html : function(v){
			if(F.unset(v)){
				return this.node.innerHTML;
			}else if(v===true){
				var div = _doc.createElement("div");
				div.appendChild(this.node.cloneNode(true));
				return div.innerHTML;
			}else if(F.isarr(v)){
				v = v.join("");	
			}else if(F.isfdom(v)||F.isnode(v)){
				v = F(v).html();
			}else if(F.isfun(v)){
				v = v(this);
			}			
			switch(this.tag){
				case "select":
					if(F.isie){
						this.empty();
						var obj = _doc.createElement("div");
						obj.innerHTML = '<select>' + v + '</select>';
						var nodes = obj.firstChild.childNodes;
						while(nodes.length>0){
							this.node.appendChild(nodes[0]);
						}
					}else{
						this.node.innerHTML = v;
					}
					if(arguments.length==2){
						this.node.value = arguments[1];
					}
					break;
				case "table":
					this.tags("tbody").item(0).html(v);
					break;
				case "thead":
				case "tfoot":
				case "tbody":
					this.empty();
					var div = _doc.createElement("div");
					div.innerHTML = "<table><tbody>"+v+"</tbody></table>";
					var ol = div.firstChild.tBodies[0].rows;
					while(ol.length>0){
						this.node.appendChild(ol[0]);
					}
					break;
				default:
					this.node.innerHTML = v;
					break;
			}
			return this;
		},			
			
		//attribute属性
		attr : function(p, v){
			var n = arguments.length;
			
			if(n==2){
				//设置单个属性				
				if(p=="style"){
					this.node.style.cssText = v;
				}else if(this.node[p]!=undefined){
					this.node[p] = v;
				}else{
					this.node.setAttribute(p,v);
				}
				return this;
			}
			if(n==1){
				//设置{key:value}对象多属性格式
				if(typeof p=="object"){
					for(var i in p){
						this.attr(i,p[i]);
					}
					return this;
				}
				
				//设置key=value字符串表达式多属性格式
				if(p.indexOf("=")>-1){
					F.each(F.trim(p).split(/\s+/), F.proxy(function(s){
						var a = s.split("=");
						this.attr(F.trim(a[0]), /["'](.+?)["']/.test(a[1]) ? RegExp.$1 : F.trim(a[1]));
					},this));
					return this;
				}
				
				//获取单个属性
				if(p=="style"){
					return this.node.style.cssText;
				}else if(p=="href"&&this.tag=="a"){
					return this.node.getAttribute(p,2);
				}else if(this.node[p]!=undefined){
					return this.node[p];
				}
				return this.node.getAttribute(p);
			}
			if(n==0){
				//获取所有属性
				var o = {};
				for(var a=this.node.attributes,l=a.length,i=0; i<l; i++){
					o[a[i].name] = a[i].value;
				}
				return o;
			}
		},
		
		//value值
		val : function(v){
			if(F.isset(v)){
				this.node.value = v;
				return this;				
			}
			return this.node.value;
		},
		
		//图片地址
		src : function(url){
			if(F.isset(url)){
				this.node.src = url;
				return this;				
			}
			return this.node.src;
		},		
		
		/*--------------6.事件-----------------*/

		//绑定事件
		bind : function(etype, fun, scope){
			etype = etype.replace(/^_/,"");
			var fdom = this;
			var scope = scope || this;
			var fun2 = function(e){fun.call(scope,F.event(e),fdom)};
			if (_win.addEventListener){
				this.node.addEventListener(etype, fun2, false);
			}else if(_win.attachEvent){
				this.node.attachEvent("on"+etype, fun2);
			}
			return RegExp.lastMatch=="_" ? fun2 : this;
		},
		
		//解除绑定
		unbind : function(etype, fun){
			if (_win.removeEventListener){
				this.node.removeEventListener(etype, fun, false);
			}else if(_win.attachEvent){
				this.node.detachEvent("on"+etype, fun);
			}
			return this;
		},
		
		//单击事件
		click : function(fun, scope){
			return this.bind("click", fun, scope);
		},
		
		//鼠标停留和移出事件
		hover : function(over_callback, out_callback){
			this.bind("mouseover", over_callback);
			this.bind("mouseout", out_callback);
			return this;
		},
		
		//主动触发事件
		fire : function(etype){
			if(F.isie){
				this.node.click();
			}else{
				evt = _doc.createEvent("MouseEvents");
				evt.initEvent("click", true, true);
				this.node.dispatchEvent(evt);
			}
			return this;
		}
	};
	
	//事件封装
	F.event = function (e){	
		e = _win.event || e;
		var o = {};
		for(var i in e){
			o[i] = F.isfun(e[i]) ? F.proxy(e,e[i]) : e[i];
		}
		if(e.target){
			o.x = e.pageX;
			o.y = e.pageY;
			o.fromTarget = e.type=="mouseover" ? e.relatedTarget : null;
			o.toTarget = e.type=="mouseout" ? e.relatedTarget : null;
		}else if(e.srcElement){
			o.target = e.scrElement;
			o.button = {1:0,4:2,2:1}[e.button];
			o.stopPropagation = function(){e.cancelBubble = true;}
			o.preventDefault = function(){e.returnValue = false;}
		}
		o.toString = F.lambda('"object Fevent"');
		return o;
	}

	"anime,drag,slides,tree,load,limitbox".replace(/\w+/g,function(method){		
		_Fwdom[method] = function(){
			return F[method].apply(F,[this].concat(F.map(arguments)));
		};
	});
	"flash,audio,video,highlight".replace(/\w+/g,function(method){
		_Fwdom[method] = function(){
			this.html(F[method].apply(F,arguments));
			return this;	
		}
	});		

	/*--------------7.对象集合操作----------------*/
	
	//Fw对象集合
	F.doms = function(v){
		var a;
		if(arguments.length>1){
			a = arguments;
		}else if(F.isfdoms(v)){
			return v;
		}else if(F.isarr(v)||F.isdoms(v)){
			a  = v;	
		}else if(F.isstr(v)){
			a = /^n:(\w+)$/.test(v) ? _doc.getElementsByName(RegExp.$1) : _doc.getElementsByTagName(v);
		}
		if(a && a.length>0){
			var data = [];
			for(var l=a.length,i=0; i<l; i++){
				data[i] = F(a[i]);
				if(!data[i]) return false;
			}		
			var methodList = [];
			for(var ii in data[0]){
				/^(?:node|init|parent|sibling|child|tags)$/.test(ii)||methodList.push(ii);
			}
			//alert(methodList);
			var f = function(data){
				this.data = data;
				this.len = data.length;
				this.isfdoms = true;
				return this;
			}
			var oo = {
				//返回对象集合链的第几个
				item : function(idx){
					if(idx<0){
						idx += this.len;
					}
					return this.data[idx];
				},
				//遍历
				each : function(fun, scope){
					var fdom;
					for(var idx=0; idx<this.len; idx++){
						fdom = this.data[idx];
						fun.call(scope||fdom,idx,fdom);
					}
					return this;
				}
			};
			for(var l=methodList.length,i=0; i<l; i++){
				(function(m){
					oo[m] = function(){
						var a = [], fdom;
						for(var j=0; j<this.len; j++){
							fdom = this.data[j];
							a[j] = fdom[m].apply(fdom, arguments);
						}
						return (a.length==0||F.isstr(a[0])||F.isnum(a[0])) ? a : this;
					}
				})(methodList[i]);
			}
			
			f.prototype = oo;
			var instance = new f(data);			
			instance.toString = function(){return "Fdoms";};
			return instance;
		}
		return false;
	}
	
	/*--------------8.dom其他----------------*/
	
	//Fdom方法扩展
	F.extend = function(method, fn){
		if(!_Fwdom[method]){
			_Fwdom[method] = fn;
		}
		return F;
	}
	
	//原生节点
	F.node = function(v){
		return F.isdom(v) ? v : F.isstr(v) ? (_doc.getElementById(v)||_doc.getElementsByName(v)[0]) : null;
	};

	
	/*====================================三、原型扩展=================================================*/
	
	//前加_ : 不作为原型
	//后加_ : 覆盖JS高版本的原型方法	
	//不加_ : 不覆盖
	var _prototype = {
		
		/*--------------1.字符串扩展----------------*/
		
		"String" : {
		
			//拼接字符串，变量和常量混合渗入
			mix : function(str, owner, more){
				if(F.unset(owner)){
					owner = _win;	
				}else if(F.isset(more)||!F.isobj(owner)){
					owner = F.map(arguments).slice(1);
				}
				return str.replace(/\$(\w+(?:\.\w+)*)\$?/g,function(s,a){
					a = a.split(".");
					var v = owner;
					while(a.length>0){
						v = v[a.shift()];
					}
					return v===undefined ? s : v;
				});
			},
			
			//删除两边的空白
			trim : function(str){
				return str.replace(/^\s+|\s+$/g,"");
			},
			
			//获取真实字节数
			bytelen : function(str){
				return str.replace(/[^\x00-\xff]/g,"aa").length;
			},
		
			//字符串复制
			repeat : function (str, times){ 
				return(new Array(times + 1)).join(str); 
			},
		
			//首字母大写
			capitalize : function(str){
				return str.charAt(0).toUpperCase() + str.substring(1); 
			},
			
			//获取真实字节数
			link_ : function(str, url, target){
				return '<a href="'+url+'"'+(target?' target="'+target+'"':'')+'>'+str+'</a>';
			}
		},
	
		/*--------------2.数字扩展----------------*/
		
		"Number" : {
			//数字补零
			zero : function(num, len){
				len = len || 2;
				return Array(len).join("0").concat(num).slice(-len);
			},
			
			//人民币格式化
			rmb : function(num, prefix){
				prefix = arguments.length<2 ? "￥" : "";
				return prefix + num.toFixed(2).replace(/(\d)(?=(?:\d{3})+(?!\d))/g,"$1,");
			},
			
			//获取两个数之间的随机数
			limit : function(num, min, max){
				return Math.min(max, Math.max(min,num));
			},
			
			//获取指定指定范围的随机数
			_rand : function (min, max){
				return Math.floor(Math.random()*(max-min+1)) + min;
			}
		},
	
		/*--------------3.数组扩展----------------*/
	
		"Array" : {
			
			//将一组元素转换成其他数组（不论是否是元素数组） 
			map_ : function(collect, callback){
				var a = [], len=collect.length;
				if(callback){
					callback = F.lambda(callback);
					for(var i=0; i<len; i++){
						a[i] = callback(collect[i],i);
					}			
				}else{
					for(var i=0; i<len; i++){
						a[i] = collect[i];
					}
				}
				return a;
			},
			
			//过滤
			filter : function(arr, fun){
				var a = [];
				for(var i=0,l=arr.length; i<l; i++){
					fun(arr[i]) && a.push(arr[i]);
				}
				return a;				
			},
			
			//选择项,方便倒序
			eq : function(arr,idx){
				if(idx<0){
					idx += arr.length;
				}
				return arr[idx];
			},
			
			//获取索引值
			index : function(arr, p, v){
				var l = arr.length;
				if(F.unset(v)){
					for(var i=0; i<l; i++){
						if(arr[i]==p){
							return i;
						}
					}
				}else{
					for(var i=0; i<l; i++){
						if(arr[i][p]==v){
							return i;
						}
					}
				}
				return -1;
			},
		
			//二分法(binary_search)
			search : function(a, num){
				var min = 0;
				var max = a.length-1;
				var i = -1;
				
				var fun = F.lambda("a");
				if(/v\.\w+/.test(num)){
					fun = F.lambda(RegExp.lastMatch);
					if(/^v\.\w+=(\d+)$/.test(num)){
						num = RegExp.$1;
					}
				}
				var minF, maxF;
				if(F.re.sint.test(num)){
					minF = new Function("n", "return n<"+num);
					maxF = new Function("n", "return n>"+num);								  
				}
				if(/^(\d+)<(=)?v(?:\.\w+)?<(=)?(\d+)$/.test(num)){
					minF = new Function("n", "return n<"+(RegExp.$2?"=":"")+RegExp.$1);
					maxF = new Function("n", "return n>"+(RegExp.$3?"=":"")+RegExp.$4);
				}				
				while(min<=max){
					i = Math.floor((min+max)/2);
					var n = fun(a[i]);
					if(minF(n)){
						min = i+1;
					}else if(maxF(n)){
						max = i-1;
					}else{
						return i;
					}
				}
				return -1;
			},
			
			//数组重排（乱序）
			shuffle : function(arr){
				return arr.slice(0).sort(function(){return Math.random()-0.5;});
			},
			
			//移除重复值
			unique : function(arr){
				var o = {}, v;
				for(var i=0; i<arr.length; i++){
					v = arr[i];
					if(o[v]){
						a.splice(i,1);
						i--;
					}else{
						o[v] = 1;
					}
				}
				return a;
			},
			
			//数组元素互换
			swap : function(arr,i,j){
				var temp = arr[i];
				arr[i] = arr[j];
				arr[j] = temp;
				return arr;
			},
			
			//二维数组排序
			sortby : function(arr, key, order){
				return arr.sort(new Function("a","b",order?F.mix("return b.$0-a.$0",key):F.mix("return a.$0-b.$0",key)));
			},
			
			//用给定的值填充数组
			_range : function (v1, v2, count){
				var a = [];
				//数字
				if(F.re.int.test(v1)&&F.re.int.test(v2)){
					var dir = v2-v1>0 ? 1 : -1;
					for(var i=0,l=Math.abs(v2-v1)+1; i<l; i++){
						a.push(v1+i*dir);
					}
				//字母其他
				}else{
					var n1=v1.charCodeAt(), n2=v2.charCodeAt();
					var dir = n2-n1>0 ? 1 : -1;
					for(var i=0,l=Math.abs(n2-n1)+1; i<l; i++){
						a.push(String.fromCharCode(n1+i*dir));
					}
				}
				return count ? F.shuffle(a).slice(0,count) : a;
			},
		
			//做为数组升序排序的简化函数
			_up : function(a,b){
				return a-b;
			}
		},
		
		/*--------------4.日期扩展----------------*/
		
		"Date" : {
			
			//日期格式化
			format : function(dat, str){
				dat = F.date(dat);
				var y=dat.getFullYear(), m=dat.getMonth()+1, d=dat.getDate();
				return str.replace(/y+/i,y)
						  .replace(/m+/i,function(s){return s.length>1?F.zero(m):m})
						  .replace(/d+/i,function(s){return s.length>1?F.zero(d):d});
			},
			
			//时间差
			diff : function(d1, d2, flag){
				var n1 = d1.getTime();
				var n2 = F.date(d2).getTime();
				var n = Math.abs(n1-n2);
				if(flag==1){
					return n;
				}
				var a = [];
				a[0] = Math.floor(n/86400000);
				n -= a[0]*86400000;
				a[1] = Math.floor(n/3600000);
				n -= a[1]*3600000;
				a[2] = Math.floor(n/60000);
				n -= a[2]*60000;
				a[3] = Math.floor(n/1000);
				n -= a[3]*1000;
				a[4] = n;
				return a;
			}
		},
				
		/*--------------5.函数扩展----------------*/
		
		"Function" : {
			
			//作用域绑定代理
			proxy : function(v1, v2){
				var args = [].slice.call(arguments,2);
				var scope = v2;
				var fun = v1;
				if(F.isfun(v2)){
					scope = v1;
					fun = v2;
				}else if(F.isstr(v2)){
					scope = v1;
					fun = scope[v2];
				}
				return function(){
					//return fun.apply(scope, [].concat.apply(args, arguments));
					return fun.apply(scope, args.concat([].slice.call(arguments)));
				};
			},
			
			//继承
			inherit : function(fun, superClass){
				fun.prototype = new superClass();
				return fun;
			}
		}
	};
	
		/*--------------6.对象扩展----------------*/
		
		//选择键值
		F.clone = function(o){
			var o2 = {};
			for(var i=1,a=arguments,l=a.length; i<l; i++){
				o2[a[i]] = o[a[i]];
			}
			return o2;
		};
		
		//删除键值
		F.cut = function(o){
			for(var i=1,a=arguments,l=a.length; i<l; i++){
				delete o[a[i]];
			}
			return o;
		};
		
		//合并到源对象，循环目标对象
		F.merge = function (source, target, $type) {
			if(F.isstr(target)){
				source[target] = $type;
				return source;
			}
			var f = new Function("o","k",["return true","return o.hasOwnProperty(k)","return !o.hasOwnProperty(k)"][$type||0]);
			for (var key in target) {
				f(source,key) &&  (source[key]=target[key]);
			}
			return source;
		};
		
		//键值翻转
		F.flip = function(hashObj){
			var o = {};
			for(var key in hashObj){
				o[hashObj[key]] = key;
			}
			return o;
		}
		
		//遍历对象
		F.each = function(json, callback){
			//如果是集合
			if(F.iscollect(json)){
				for(var idx=0,l=json.length; idx<l; idx++){
					callback(json[idx], idx);
				}
			}else{
				for(var key in json){
					callback(json[key], key);
				}
			}
			return F;
		};

		for(var tp in _prototype){
			F.each(_prototype[tp], function(fun, method){
				F[method.replace(/^_|_$/,"")] = fun;
			});
		}
		

	/*====================================四、AJAX|请求相关=================================================*/

	//xmlhttp对象(格式化的AJAX对象)
	var _XHR = (function(){
		if (_win.XMLHttpRequest){
			return XMLHttpRequest;
		}
		var a = ["Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.5.0"];
		for (var i=0,l=a.length;i<l;i++){
			try{
				var X = new ActiveXObject(a[i]);
				return function(){return X;};
			}catch(e){}
		}
		return false;
	})();
	
	//ajax类
	F.ajax = F.Class({
		init : function(ops){
			this.url = ops.url;
			this.data = "";
			if(ops.data){
				if(F.isnode(ops.data)){
					ops.data = F.getForm(ops.data);
				}
				this.data = F.serialize(ops.data, ops.isEncode||0);
			}
			this.method = ops.method || "get";
			this.charset = ops.charset || "utf-8";
			ops.obj && this.callback(F.proxy(ops.obj,"html"));
			return this;
		},
		//回调返回JSON数据
		call2json : function(fun){
			this.callback(fun,"json");
		},
		//回调，默认返回字符串
		callback : function(fun, $type){
			if(this.method=="get"&&this.data!=""){
				this.url += (this.url.indexOf("?")>-1?"&":"?") + this.data;
				this.data = "";
			}

			var x = new _XHR();
			x.open(this.method, this.url, true);	//第3个参数固定为true，异步提交
			this.method=="post" && x.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset="+this.charset);
			if(fun){
				//解析字符串格式的函数
				if(F.isstr(fun)){
					var a = fun.split(".");
					var scope = _win;
					while(a.length>1){
						scope = scope[a.shift()];
					}
					fun = F.proxy(scope, a[0]);
				}
				x.onreadystatechange = function(){
					x.readyState==4&&(x.status==0||x.status==200) && fun($type=="json"?F.json_parse(x.responseText):x.responseText);
				};
			}
			x.send(this.data);
		}
	});
	
	//ajax的get请求
	F.get = function(url,data){
		return F.ajax({url:url,data:data,method:"get"});
	};
	
	//ajax的post请求
	F.post = function(url,data){
		return F.ajax({url:url,data:data,method:"post"});
	};
	
	//ajax异步加载HTML代码
	F.load = function(fo,url,data){
		var o = {url:url, obj:fo};
		if(data){
			o.method = "post";
			o.data = data;	
		}
		return F.ajax(o);		
	};

	//动态加载JS
	var _jsfiles = {};
	F.js = function(url, callback){
		if(_jsfiles[url]){
			return callback && callback();
		}
		_jsfiles[url] = true;
		
		if(Fw_map[url]){
			url = /^http:\/\//.test(Fw_map[url]) ? Fw_map[url] : F.data("fw/"+Fw_map[url]);
		}

		var fo = _head.append("script").attr("type","text/javascript").src(url);
		callback && _loadFileCallback(fo, callback);
		return fo;
	}
	
	//加载文件回调
	var _loadFileCallback = function(fo, callback){
		var obj = fo.node;
		if(obj.readyState){
			obj.onreadystatechange = function(){
				(obj.readyState=='loaded'||obj.readyState=='complete') && fo.remove() && callback && callback();
			};
		}else{
			var intervalID = setInterval(function() {
				try{
					obj.sheet.cssRules;
					_win.clearInterval(intervalID);
					callback();
				}catch(e){}
			},100);
			obj.onload = function(){
				fo.remove() && callback && callback();
			};
		}
		return this;
	};

	//动态加载CSS文件
	var _cssfiles = {};	
	F.css = function(v, callback){
		if(F.isarr(v)){
			v = v.join("\n");	
		}
		
		if(/{[\w\W]+?}/.test(v)){
			var dom = _head.append("style").attr("type","text/css");
			dom.node.styleSheet && (dom.node.styleSheet.cssText=v) || dom.node.appendChild(_doc.createTextNode(v));
			return dom;
		}

		if(_cssfiles[v]){
			return callback && callback();
		}
		var fo = _cssfiles[v] = _head.append("link").attr({rel:"stylesheet",type:"text/css",href:v});
		callback && _loadFileCallback(fo, callback);
		return _cssfiles[v];		
	};
	
	//加载图片
	F.img = F.loadImg = function(imgs, itemLoaded, allLoaded){
		var me = this;
		imgs = imgs.split(",");		//图片数组
		var count = imgs.length;	//图片总数
		var idx = 0;				//已经被加载的图片个数
		var fun = function(){
			idx++;
			itemLoaded && itemLoaded(idx, count, this);
			if (idx<count) return down();
			allLoaded && allLoaded();
		};
		var down = function () {
			var img = new Image();
			img.onload = fun;
			img.src = imgs[idx];
		};
		down();
		return this;
	};

	//生成flash
	F.flash = function (url, width, height, param){
		var tagName = "", o1 = {width:width||1, height:height||1}, o2 = {};
		if (F.browser[0]=="msie"){
			tagName = "object ";
			o1.classid = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
			o1.codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0";
			o2.movie = url;
			o2.quality = "high";
			param && F.merge(o2, param);
		}else{
			tagName = "embed ";
			o1.type = "application/x-shockwave-flash";
			o1.pluginspage = "http://www.macromedia.com/go/getflashplayer";
			o1.src = url;
			o1.quality = "high";
			param && F.merge(o1, param);
		}
		if(o1.width<2&&o1.height<2) tagName+='style="position:absolute; top:-100px;" ';
		var a1=[], a2=[], i;
		for(i in o1) a1.push(i+'="'+o1[i]+'"');
		for(i in o2) a2.push('<param name="'+i+'" value="'+o2[i]+'" />');
		return '<'+tagName+a1.join(' ')+'>'+a2.join('')+'</'+tagName+'>';
	};
	
	//播放器生成代码
	F.audio = function (url, width, height, param){
		var wmp = ["6bf52a52-394a-11d3-b153-00c04f79faa6","application/x-mplayer2"];
		var rmp = ["CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA","audio/x-pn-realaudio-plugin"];
		var mp = /\.rm$/.test(url) ? rmp : wmp;
	
		var tagName = "", o1 = {width:width||1, height:height||1}, o2 = {};
		if (F.isie){
			tagName = "object ";
			o1.classid = "clsid:"+mp[0];
			o2.url = url;
			param && F.merge(o2, param);
		}else{
			tagName = "embed ";
			o1.type = mp[1];
			o1.src = url;
			param && F.merge(o1, param);
		}
		if(o1.width<2&&o1.height<2) tagName+='style="position:absolute; top:-100px;" ';
		var a1=[], a2=[], i;
		for(i in o1) a1.push(i+'="'+o1[i]+'"');
		for(i in o2) a2.push('<param name="'+i+'" value="'+o2[i]+'" />');
		return '<'+tagName+a1.join(' ')+'>'+a2.join('')+'</'+tagName+'>';
	};
	
	//视频生成代码
	F.video = function (url, width, height, param){
		return F.audio(url, width, height, param);
	};
	
	
	/*====================================五、表单相关=================================================*/
	
	//自定义表单
	//参考自jquery.HooRay
	F.diyForm = function(obj){
		var btns = [];
		var rds = {};
		var box = F(obj);
		var chkRadio = function(input){
			var idx = input.attr("btnIdx");
			var oldIdx = rds[input.node.name];
			if(oldIdx&&oldIdx==idx) return;

			if(F.isset(oldIdx)){
				btns[oldIdx].bgpos(0,0); 
			}
			rds[input.node.name] = idx;
			btns[idx].bgpos(0,-36);
		};
		var chkCheckbox = function(input){
			btns[input.attr("btnIdx")].bgpos(0, input.node.checked?-36:0);			 
		};
		box.tags("input").each(function(idx, fo){
			var $type = fo.attr("type");
			if($type=="radio"||$type=="checkbox"){
				var skinId = fo.attr("skin");
				if(skinId){
					var input = fo.size(20,15).opacity(0).attr("btnIdx",idx);
					var o = input.abspos(1);
					var u = F.data("img/diyForm/skin/"+$type+skinId+".png");
					btns[idx] = F().append("div").css("zIndex",-1).bgimg(u).bgpos(0,0).ps().rect(o.x,o.y,18,18);
					if($type=="radio"){
						input.node.checked && chkRadio(input);
						input.click(F.proxy(null,chkRadio,input));	
					}else if($type=="checkbox"){
						chkCheckbox(input);
						input.click(F.proxy(null,chkCheckbox,input));
					}
				}
			}else if($type=="file" && fo.attr("skin")){
				var input = fo.size(70,25).opacity(0).attr("btnIdx",idx);
				var o = input.abspos(1);				
				if(fo.attr("skin")=="button"){
					btns[idx] = F().append("button").html(fo.attr("val")).css("zIndex",-1).ps().rect(o.x,o.y,70,25);	
				}
			}
		});
		return box;
	};
	
	//获取表单所有的值
	F.getForm = function(form){
		form = F(form).node;
		var o = {};
		F.each(form.elements, function(obj){
			if(obj.name && obj.disabled==false){
				if(obj.type=="radio"||obj.type=="checkbox"){
					if(obj.checked){
						o[obj.name] = (F.isset(o[obj.name])?o[obj.name]+",":"") + obj.value;
					}
				}else{
					o[obj.name] = obj.value;
				}
			}
		});
		return o;
	};
	
	//表单赋值
	F.setForm = function(form, o){
		form = F(form).node;
		for (var name in o){
			if(!form[name]){
				throw name +" is not a name in the form: " + form.name;
			}
			var obj = form[name];
			if(obj.length){
				if(obj[0].type=="radio"){
					F.each(form[name], function(obj){
						obj.checked = obj.value==o[name];			
					});
				}else if(obj[0].type=="checkbox"){
					var aa = F.isarr ? o[name] : o[name].split(",");
					F.each(form[name], function(obj,i){
						obj.checked = F.index(aa, obj.value)>-1;			
					});
				}
			}else{
				obj.value = o[name];
			}
		}
		return this;
	};
	

	//case "select": if(!this.select(td2.tags("select").item(0), ti))return false;
	//case "radio" : if(!this.radio(td2.tags("input"), ti))return false; break;
	//case "checkbox" : if(!this.checkbox(td2.tags("input"), ti))return false; break;
	
	//表单验证组件
	F.validator = function(objForm){
		objForm = F(objForm);
		var form = objForm.node;

		//验证
		var chks = function(obj){
			var v = obj.bg("#fff").val();
			var doms = obj.sibling(">"), fo;
			if(!doms) return true;
			doms.hide();
			for(var i=0; i<doms.len; i++){
				fo = doms.item(i);
				switch(fo.tag){
					case "i":
						if(!chk(fo,v)){
							obj.bg("#ffe7e7") && fo.show("inline") && obj.node.focus();
							return false;
						}
						break;
					case "u":
						if(obj.attr("passkey")!=v){
							fo.show("inline");
							F.get(fo.attr("url"), {chk:obj.attr("name"),val:v}).callback(F.proxy(this,function(fo,obj,n){
								fo.hide().sibling(n).show("inline");							
								n>1 ? obj.bg("#ffe7e7") && obj.node.focus() : obj.attr("passkey",v) && chkForm(2);
							},fo,obj));
							return false;
						}
						break;
					case "b":
						v!="" && fo.show("inline");
						return true;
				}
			}
			return true;
		}
		
		//验证单个
		var chk = function(obj,v){
			var o = obj.attr();
			if(F.isset(o.required)){
				return v!="";
			}
			if(F.isset(o.empty) && v==""){
				return true;	
			}
			return ( F.unset(o.re) || F.re[o.re].test(v) )
				&& ( F.unset(o.pattern) || new RegExp(o.pattern).test(v) )
				&& ( F.unset(o.minlen) || v.length>=o.minlen )
				&& ( F.unset(o.maxlen) || v.length<=o.maxlen )
				&& ( F.unset(o.min) || v>=o.min )
				&& ( F.unset(o.max) || v<=o.max )
				&& ( F.unset(o.pwd) || v==form[o.pwd].value);
		}
		
		//验证绑定
		var obj;
		for(var eles=form.elements,l=eles.length,i=0; i<l; i++){
			obj = F(eles[i]);
			obj.bind("blur",F.proxy(null,chks,obj));
		}
		
		//提交验证
		var chkForm = function(flag){
			for(var eles=form.elements,l=eles.length,i=0; i<l; i++){
				if(!chks(F(eles[i]))) return false;
			}
			var o = objForm.attr();
			if(o.ajax){
				F.ajax({url:o.action,method:o.method||"get",data:form}).callback(o.callback);
				return false;
			}
			flag==2 && form.submit();
			return true;
		}
		form.onsubmit = chkForm;
	};

	//获取或设置单选框的值
	F.radio = function (obj, val){
		var ol = F.doms(F.isstr(obj)?"n:"+obj:obj);
		
		//获取
		if(F.unset(val)){
			for(var i=0; i<ol.len; i++){
				if(ol.item(i).node.checked){
					return ol.item(i).val();
				}
			}
			return false;
		}
		
		//设置
		for(var i=0; i<ol.len; i++){
			if(ol.item(i).val()==val){
				ol.item(i).node.checked = true;
				break;
			}
		}
		return this;		
	};
	
	//获取或设置复选框的值
	F.checkbox = function (obj, v){
		var ol = F.doms(F.isstr(obj)?"n:"+obj:obj);
		
		//获取
		if(F.unset(v)){
			var a = [];
			ol.each(function(){
				this.node.checked && a.push(this.val());
			});
			return a;
		}
		
		//设置
		ol.each(function(idx){
			this.node.checked = v[idx]==1;
		});
		return this;
	};

	//全选/反选/清除功能
	F.selectall = function(v){
		return this;
	};
	
	//只能输入数字
	F.limitbox = function(obj, re){
		var re = re || /[^\d\.]/g;
		re = F.isstr(re) ? F.re[re] : re;
		F(obj).bind("keyup", function(){
			this.val(this.val().replace(re,''));
		});
		return this;
	};
	
	//输入框提示
	F.tipbox = function(obj){
		obj = F(obj).node;
		var msg = obj.value;
		obj.onfocus = function(){
			if(obj.value==msg) obj.value="";
		};
		obj.onblur = function(){
			if(obj.value=="") obj.value=msg;
		};
		return msg;
	};
	
	//代码框
	F.codebox = function(v){
		return this;
	};
	
	/*===========================================六、编码解码========================================*/
	
	//Object对象转换为JSON字符串
	F.json_stringify = function(jsonObj){
		var obj2str = function(v){
			if(v==undefined) return v;
			switch(v.constructor){
				case Number:
				case Boolean:
					return v;			
				case String:
					return '"' + v + '"';
				case Array:
					var a = [];
					for(var i=0,l=v.length; i<l; i++){
						a.push(obj2str(v[i]));
					}
					return "[" + a.join(",") + "]";
				case Object:
					var a = [];
					for(var i in v){
						a.push('"'+i+'":'+obj2str(v[i]));
					}
					return "{" + a.join(",") + "}";
				default:
					return undefined;
			}
		};
		return obj2str(jsonObj);
	};
	
	//JSON字符串转换为Object对象
	F.json_parse = function(jsonStr){
		if(F.isstr(jsonStr)){		
			try{
				return eval('(' + jsonStr + ')');
			}catch(e){return false;}
		}else{
			return jsonStr;	
		}
	}

	//URL编码
	F.url_encode = function(str){
		//return s.replace(/&/g,"%26").replace(/\+/g,"%2b").replace(/\'/g,"''");
		return str
			.replace(/%/g,'%25')
			.replace(/ /g,'%20')
			.replace(/#/g,'%23')
			.replace(/&/g,'%26')
			.replace(/=/g,'%3D')
			.replace(/\//g,'%2F')
			.replace(/\?/g,'%3F')
			.replace(/\+/g,'%2B');
	};
	
	//URL解码
	F.url_decode = function(s){
		//return s.replace(/%26/g,"&").replace(/%2b/g,"+").replace(/\'\'/g,"'");
	};	
	
	//HTML特殊字符编码
	F.html_encode = function(str, flag){
		str = str.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
		flag = flag || 0;
		if(flag==1||flag==3) str = str.replace(/'/,"&#039;");
		if(flag==2||flag==3) str = str.replace(/"/g,"&quot;");
		return str;
	}
	
	//HTML解码
	F.html_decode = function(str, flag){
		flag = flag || 0;
		if(flag==1||falg==3) str = str.replace(/&#039;/,"'");
		if(flag==2||falg==3) str = str.replace(/&quot;/g,'"');
		return str.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");
	}	

	//把对象序列化为字符串
	F.serialize = function (json, isEncode) {
		if(F.isstr(json)){
			return json;
		}
		var a = [], val;
		for (var key in json) {
			val = isEncode ? F.url_encode(json[key]) : json[key];
			a.push(key+"="+val);
		}
		return a.join("&");
	};

	//把字符串反序列化为对象
	F.unserialize = function(str){
		var o = {}, a;
		for (var aa=str.split("&"),l=aa.length,i=0; i<l; i++) {
			a = aa[i].split("=");
			o[a[0]] = a[1];
		}
		return o;
	};
	
	//自定义编码
	F.encode = function(str){
		return str.replace(/[^\u0000-\u00FF]/g,function($0){
			var v="",n,l="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
			n=escape($0).replace("%u","0x")*1
			do{v=l.substr(n%62,1)+v;n=parseInt(n/62)}
			while(n>0||v.length<3)
			return "{*"+v+"}"
		}).replace(/\}\{\*/g,"")
	};
	
	//自定义解码
	F.decode = function(str){
		return str.replace(/\{\*[^\}]*\}/g,function($0){
			return $0.slice(2,-1).replace(/\w{3}/g,function($1){
				var v=$1,i,n=0,l="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
				for(i=0;i<v.length;i++){
					n+=l.indexOf(v.substr(i,1))*Math.pow(62,v.length-i-1)
				}
				v=n.toString(16)
				return unescape("%u"+(v.length<4?"0":"")+v)
			})
		})
	};
	
	
	/*====================================获取框架路径及设置prototype原型继承==========================================*/
	
	var _head = F.doms("head").item(0);
	
	var _src = F.doms("script").item(-1).src();
	//路径
	F.path = /^http:\/\/.+?(\/.+)F\.js.*$/.test(_src) ? RegExp.$1 : _src.replace("1st.js","");

	var o = F.unserialize(_src.replace(/^.+\?/,""));
	F.config = {ns:F.isset(o.ns)?o.ns:ns, pt:F.isset(o.pt)?+o.pt:pt};
	if(F.config.pt){
		_prototype["Array"].each = F.each;
		var ppt;
		for(var tp in _prototype){
			ppt = _win[tp].prototype;
			F.each(_prototype[tp], function(fun, key){
				if(/^[a-z]/i.test(key) && !ppt[key]){
					key = key.replace(/_$/,"");
					ppt[key] = function(){return fun.apply(null,[this].concat(F.map(arguments)))};
				}
			});
		}
	}
	F.config.ns && (_win[F.config.ns]=F);
})("F",1, {jq:"jquery1.4.2.min.js", ext:"", moo:"", "1kjs":"1k.js"});
		
		
		
		
		


/*===========================================七、Fw内部组件========================================*/


//动画组件
~function(F){
	F.anime = function (node, args){
		var fo=F(node), tp=_EASING[args.type||'Both'], s0=0, s1=Math.ceil((args.duration||1000)/16), timer, items=[], len, o, n,
		additem = function(key, scale, key2){
			if(F.isset(args[key])){
				var n = fo[key]();
				var i = args[key];
				var o = {method:F.proxy(fo,key), origin:n, incriment:F.isnum(i)?i-n:+i};
				scale && F.merge(o,{scale:scale, method2:F.proxy(fo,key2), origin2:fo[key2]()});
				items.push(o);
				
				if(key=="left"||key=="top"||scale){
					fo.ps()=="static" && fo.ps("relative");
					F.isie6 && (key=="width"||key=="height") && F.css("overflow", "hidden");
				}
			}
		}
		F.isie && F.browser[1].charAt(0)<8 && fo.css("zoom",1);
		additem("width", args.ws, "left");
		additem("height", args.hs, "top");
		"left,top,opacity,scrollLeft,scrollTop".replace(/\w+/g,function(s){additem(s)});
		len = items.length;

		function _doing(){
			if(s0<s1){
				for(var i=0; i<len; i++){
					o = items[i];
					o.method(n=tp(s0,o.origin,o.incriment,s1)) && o.scale && o.method2(o.origin2-o.scale*(n-o.origin));
				}
				s0++;
				timer = setTimeout(_doing,16);
			}else{
				for(var i=0; i<len; i++){
					o = items[i];
					o.method(o.origin+o.incriment) && o.scale && o.method2(o.origin2-o.scale*o.incriment);
				}
				args.after && args.after();
			}
			args.running && args.running(fo);
		}
		args.before && args.before();
		timer = setTimeout(_doing,16);
		return{
			stop:function(){
				if(!args.lock)clearTimeout(timer);
				args.stop && args.stop();
			}
		};
	};
	
	//t=当前步数 b=原点 c=增量 d=总步数
	var _EASING = {
		Linear: function(t,b,c,d){ return c*t/d + b; },
		slowIn:function(t,b,c,d){return c*(t/=d)*t + b;},
		slowOut:function(t,b,c,d){return -c *(t/=d)*(t-2) + b;},
		slowBoth:function(t,b,c,d){
			if ((t/=d/2) < 1) return c/2*t*t + b;
			return -c/2 * ((--t)*(t-2) - 1) + b;
		},
		In: function(t,b,c,d){
			return c*(t/=d)*t*t*t + b;
		},
		Out: function(t,b,c,d){
			return -c * ((t=t/d-1)*t*t*t - 1) + b;
		},
		Both: function(t,b,c,d){
			if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
			return -c/2 * ((t-=2)*t*t*t - 2) + b;
		},
		fastIn: function(t,b,c,d){
			return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
		},
		fastOut: function(t,b,c,d){
			return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
		},
		fastBoth: function(t,b,c,d){
			if (t==0) return b;
			if (t==d) return b+c;
			if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
			return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
		},
		circIn: function(t,b,c,d){
			return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
		},
		circOut: function(t,b,c,d){
			return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
		},
		circBoth: function(t,b,c,d){
			if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
			return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
		},
		elasticIn: function(t,b,c,d,a,p){
			if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
			if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
			else var s = p/(2*Math.PI) * Math.asin (c/a);
			return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		},
		elasticOut: function(t,b,c,d,a,p){
			if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
			if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
			else var s = p/(2*Math.PI) * Math.asin (c/a);
			return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b);
		},
		elasticBoth: function(t,b,c,d,a,p){
			if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
			if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
			else var s = p/(2*Math.PI) * Math.asin (c/a);
			if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
			return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
		},
		backIn: function(t,b,c,d,s){
			if (s == undefined) s = 1.70158;
			return c*(t/=d)*t*((s+1)*t - s) + b;
		},
		backOut: function(t,b,c,d,s){
			if (s == undefined) s = 1.70158;
			return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
		},
		backBoth: function(t,b,c,d,s){
			if (s == undefined) s = 1.70158; 
			if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
			return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
		},
		bounceIn: function(t,b,c,d){
			return c - _EASING.bounceOut(d-t, 0, c, d) + b;
		},
		bounceOut: function(t,b,c,d){
			if ((t/=d) < (1/2.75)) {
				return c*(7.5625*t*t) + b;
			} else if (t < (2/2.75)) {
				return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
			} else if (t < (2.5/2.75)) {
				return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
			} else {
				return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
			}
		},
		bounceBoth: function(t,b,c,d){
			if (t < d/2) return _EASING.bounceIn(t*2, 0, c, d) * .5 + b;
			else return _EASING.bounceOut(t*2-d, 0, c, d) * .5 + c*.5 + b;
		}
	};
}($1stjs);


//拖动组件
~function(F){
	F.drag = F.Class({
		init : function (box, ops){
			this.x = 0;
			this.y = 0;
			this.islimit = 0;
			this.box = F(box);
			this.box.css("position")=="static" && this.box.ps();
			this.doc = F(document);
			ops = ops || {};
			this.handle = F(ops.handle) || this.box;
			this.handle.bind("mousedown", this._down, this);

			//限制拖动范围
			this.x1 = F.isset(ops.x1) ? ops.x1 : -Infinity;
			this.y1 = F.isset(ops.y1) ? ops.y1 : -Infinity;
			this.x2 = (F.isset(ops.x2)?ops.x2:Infinity) - this.box.width();
			this.y2 = (F.isset(ops.y2)?ops.y2:Infinity) - this.box.height();
			
			//设置事件
			this.before = ops.before;
			this.running = ops.running;
			this.after = ops.after;
			this.allowX = !ops.lockX;
			this.allowY = !ops.lockY;
		},
		//鼠标按下
		_down : function (e){
			e.stopPropagation();
			if(e.button>0||this.box.node.___resizing)return;
			
			if(this.allowX){
				this.x = e.x - this.box.left();
			}
			if(this.allowY){
				this.y = e.y - this.box.top();
			}
			this.before && this.before(this);
			this.moveFun = this.doc.bind("_mousemove", this._move, this);
			this.upFun = this.doc.bind("_mouseup" ,this._drop, this);
			
			this.handle.node.setCapture && this.handle.node.setCapture(false);
			e.preventDefault();
		},
		//鼠标移动
		_move : function (e){
			window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
			this.allowX && this.box.left(F.limit(e.clientX-this.x, this.x1, this.x2));
			this.allowY && this.box.top(F.limit(e.clientY-this.y, this.y1, this.y2));
			this.running && this.running(this);
		},
		//鼠标弹起
		_drop : function(e){
			this.handle.node.releaseCapture && this.handle.node.releaseCapture();
			this.doc.unbind("mousemove",this.moveFun).unbind("mouseup",this.upFun);
			this.after && this.after(this);		
		}
	});
}($1stjs);


//弹窗组件
//参考自ymPrompt
~function(F){
	F.dialog = F.Class({
		//初始化
		init : function(ops){
			var skin = ops.skin || "vista";
			
			ops = ops || {};
			this.title = ops.title || "1stjs对话框";
			this.content = ops.content || "";
			if(ops.url){
				this.content = F.mix('<iframe src="$url" style="width:100%; height:100%;" frameborder="no" border="0" marginwidth="0" marginheight="0"></iframe>',ops);
			}
			this.width = ops.width || 300;
			this.height = ops.height || 200;
			this.box = F().append("div").ps().size(this.width,this.height).center().hide();
			F.isie6 && this.box.full("iframe").px("borderWidth",0);
			var tb = this.box.full("table").attr("cellspacing=0 cellpadding=0 height="+this.height).css("font-size:12px;").append("tbody");
			
			var tr1 = tb.append("tr.top");
			tr1.append("td.topleft");			
			var td12 = tr1.append("td.topbar");
			var title = td12.append("div.title").html(this.title);
			var div = td12.append("div.icon");
			div.append("div.min").attr("title=最小化").click(this.hide,this);
			div.append("div.max").attr("title=最大化").click(this.hide,this);			
			var closeIcon = div.append("div.close").attr("title=关闭").click(this.hide,this);
			tr1.append("td.topright");
			this.box.drag(title);
		
			var tr2 = tb.append("tr.middle");//.bg("#fff");
			tr2.append("td.leftbar").append("div");
			var td22 = tr2.append("td.body");
			td22.append("div.content").html(this.content);

			if(ops.yes||ops.no){
				var div = td22.append("div.btnbox").align("right");
				this._setbtn(div, "确定", ops.yes);
				this._setbtn(div, "取消", ops.no);
			}
			tr2.append("td.rightbar").append("div");

			var tr3 = tb.append("tr.bottom");
			tr3.append("td.bottomleft");
			tr3.append("td.bottombar");
			tr3.append("td.bottomright");
			
			ops.init && ops.init(this);	
			this.chgSkin(skin);
			return this;
		},
		chgSkin : function(skin){
			var box = this.box.cls("firstjs_dialog_"+skin), h=this.height;
			F.css(F.data("img/dialog/"+skin+"/skin.css"), function(){
				var icon = box.cls(".close");
				icon.html(icon.bgimg()=="none"?"×":"");
				var ch = h - box.cls(".top").height() - box.cls(".bottom").height();
				var div = box.cls(".leftbar").first();
				div.width() && div.height(ch) && box.cls(".rightbar").first().height(ch);
				var btnbox = box.cls(".btnbox");
				if(btnbox){
					ch -= 41;//btnbox.height();
				}
				box.cls(".content").height(ch);				
			});			
		},
		//触发器
		trigger : function(obj){
			F(obj).click(this.show,this);
			return this;
		},
		//显示
		show : function(){
			this.box.toggle();//.anime("top",String(-this.h),this.step).play();
			return this;
		},
		//隐藏
		hide : function(){
			this.box.hide();
			//this.box.anime("top",String(this.h),this.step).bind("after", F.proxy(this.box,"hide")).play();
			return this;
		},	
		//设置按钮
		_setbtn : function(obj, text, fun){
			if(fun){
				obj = obj.append("input.btn").attr("type=button").val(text);
				if(F.isnum(fun)){
					obj.click(this.hide,this);
				}else if(F.isfun(fun)){
					obj.click(function(){
						fun() && this.hide();
					}, this);
				}
			}
		},
		//定位
		_pos : function(x,y){
			if(arguments.length==1){
				this.box.center();	
			}else{
				this.box.pos(x,y);
			}
		}
	});
}($1stjs);


//幻灯片组件
~function(F){
	F.slides = F.Class({
		init : function(obj, ops){
			obj = F(obj);
			ops = ops || {};
			this.count = 0;
			this.ispause = 0;
			this.isplay = 0;
			this.nowIdx = ops.index || 0;
			this.oldIdx = this.oldIndex = this.nowIndex = 0;
			this.autoplay = ops.autoplay || 0;
			this.duration = ops.duration || 500;
			this.autoplay = 0;
			this.delay = 0;
			if(ops.autoplay){
				this.autoplay = 1;
				this.delay = ops.autoplay;
			}
			this.increment = ops.increment || 0;
			this.loop = F.isset(ops.loop) ? ops.loop : 1;
			this.ani = {};
			this.tab = this.parseAni(obj, ops, "tab");
			this.panel = this.parseAni(obj, ops, "panel");
			this.title = this.parseAni(obj, ops, "title");
			if(this.tab){
				this.tab.each(F.proxy(function(idx, fdom){
					fdom.bind(ops.etype||"click", F.proxy(this,this.go2play,idx));
				},this));
				this.css_cur = this.tab.item(this.nowIdx).cls();
				this.css_nor = this.tab.item(this.nowIdx==0?1:0).cls();
			}			
			this.prev = obj.cls(".prev");
			this.next = obj.cls(".next");
			this.prev && this.prev.click(this.go2prev,this);
			this.next && this.next.click(this.go2next,this);
			
			if(ops.onchange){
				this.onchange = ops.onchange;
			}			
			if(ops.aniAfter){
				this.aniAfter = ops.aniAfter;
			}			
			ops.init && ops.init(this);
			this.chk();
			return this;
		},
		//解析动画
		parseAni : function(obj, ops, tag){
			var dom = obj.cls("."+tag);
			if(!dom){
				return false;
			}
			var doms = dom.child();
			var me = this;			
			this.count = Math.max(this.count, doms.len);
			this.itemCount = this.count;
			var ani = ops[tag];
			if(F.isfun(ani)){
				this.ani[tag] = ani;
				return doms;
			}
			
			//以下只适用于panel
			
			if(ani=="fade"){
				doms.item(this.nowIdx).sibling().opacity(0.5);
				this.ani.panel = function(){
					me.isplay = 1;
					doms.item(me.oldIdx).anime({
						opacity: 0.5,
						duration: me.duration/2,
						after: function(){
							doms.item(me.oldIdx).hide();
							doms.item(me.nowIdx).show().anime({opacity:1,duration:me.duration/2,after:F.proxy(me,me.unlock,tag)});
						}
					});
				};
				return doms;
			}
			
			if(ani=="scrollLeft"||ani=="scrollTop"){
				this.method = ani;
				var o, box=dom;
				if(ani=="scrollLeft"){
					var wrap = obj.cls(".wrap");
					if(wrap){
						var nodes = wrap.child();
						var fo = nodes.item(0);
						wrap.width((fo.node.offsetWidth+fo.px("marginLeft")+fo.px("marginRight"))*nodes.len);
						nodes.float();				
						box = wrap;					
					}
					this.boxlen = dom.node.offsetWidth;
					this.conlen = dom.node.scrollWidth;			
					
				}else if(ani=="scrollTop"){
					this.boxlen = dom.node.offsetHeight;
					this.conlen = dom.node.scrollHeight;
				}
				this.increment = this.increment || this.boxlen;				
				this.itemCount = Math.ceil(this.conlen/this.increment);
				this.count = this.itemCount;				
				if(this.loop==2){
					//if(this.conlen<this.boxlen*2){
						this.count *= 2;
						wrap && wrap.width(this.conlen*2);
						var ol = box.node.cloneNode(true);
						while(ol.firstChild){
							box.node.appendChild(ol.firstChild);
						}
				}				
				this.ani.panel = function(){
					me.isplay = 1;
					var m = me.nowIdx>=me.count ? 0 : me.nowIdx;
					var ops = {};
					ops.type = me.delay ? "circOut" : "Linear";
					ops.duration = me.duration;
					ops[me.method] = m * me.increment;
					ops.after = F.proxy(me,me.unlock,"panel");					
					dom.anime(ops);
				};
				return dom;
			}
			
			return doms;
		},		
		//解锁
		unlock : function(tag){
			this.isplay = 0;
			this.aniAfter && this.aniAfter(this,tag);
			this.chk();
		},
		//检查
		chk : function(){
			if(this.ispause) return;
			
			if(this.isplay==0){
				this.oldIdx = this.nowIdx;
				this.oldIndex = this.oldIdx%this.itemCount;
				this.nowIndex = this.nowIdx%this.itemCount;
				if(this.autoplay){
					if(this.delay>1){
						this.timer = window.setTimeout(F.proxy(this,this.go2next), this.delay);
						return;
					}
					this.go2next();
				}
			}
		},
		//上一个
		go2prev: function(){
			if(this.loop==0&&this.oldIdx==0){
				return;
			}
			this.nowIdx = this.oldIdx-1;
			if(this.nowIdx<0){
				this.loop==2 && this.panel[this.method](this.conlen);
				this.nowIdx = this.itemCount-1;
			}
			this._switch();
		},		
		//下一个
		go2next: function(){
			if(this.loop==0&&this.oldIdx==this.count-1){
				return;
			}
			this.nowIdx = this.oldIdx+1;
			if(this.loop==2){
				if(this.nowIdx>this.itemCount){
					this.panel[this.method](0);
					this.nowIdx = 1;
				}
			}else{
				if(this.nowIdx>=this.itemCount){
					this.nowIdx = 0;
				}				
			}
			this._switch();
		},
		//跳播
		go2play : function(idx){
			if(this.isplay){
				return;
			}
			this.nowIdx = idx;
			this.nowIndex = this.nowIdx%this.itemCount;
			this._switch();
		},	
		//停止
		stop : function(){
			window.clearTimeout(this.timer);
		},
		//新旧切换
		_switch : function(){
			if(this.oldIdx==this.nowIdx){
				return;
			}
			this.stop();
			this.oldIndex = this.oldIdx%this.itemCount;
			this.nowIndex = this.nowIdx%this.itemCount;
			this.onchange && this.onchange(this);
			if(this.tab){
				this.ani.tab ? this.ani.tab(this) :
				this.tab.item(this.oldIndex).cls(this.css_nor) && this.tab.item(this.nowIndex).cls(this.css_cur);
			}
			if(this.title){
				this.ani.title ? this.ani.title(this) :
				this.title.item(this.oldIndex).hide() && this.title.item(this.nowIndex).show();
			}
			if(this.panel){
				this.ani.panel ? this.ani.panel(this) :
				this.panel.item(this.oldIndex).hide() && this.panel.item(this.nowIndex).show();	
			}
			this.chk();
		}
	});
}($1stjs);


//分页类
~function(F){
	F.pagination = F.Class({
		init : function(box, cb){
			this.num = 0;
			this.pagenum = 0;
			this.page = 1;
			this.size = 10;
			this.maxsize = 100;
			this.cb = cb;
			
			var box = F(box);
			this.inihtm(box);
			var a = box.tags("a");
			var b = box.tags("b");
			var i = box.tags("input");
			var bt = box.tags("button");
			this.fo = {box:box, num:b.item(0), pagenum:b.item(1), page:b.item(2), size:i.item(0), pageIdx:i.item(1)};
			a.item(0).click(this.go2first,this);
			a.item(1).click(this.go2pre,this);
			a.item(2).click(this.go2next,this);
			a.item(3).click(this.go2last,this);
			bt.item(0).click(this.chksize,this);
			bt.item(1).click(this.chgsize,this);
			bt.item(2).click(this.chkpage,this);
			return this;
		},
		//设置页个数
		setsize : function(n){
			this.size = n;
			return this;
		},
		//设置页数
		setpage : function(n){
			this.page = n;
			return this;
		},	
		//跳到第一页
		go2first : function(){
			this.page!=1 && this.chgpage(1);
		},
		//跳到上一页
		go2pre : function(){
			this.page-1>0 && this.chgpage(this.page-1);
		},
		//跳到下一页
		go2next : function(){
			this.page+1<=this.pagenum && this.chgpage(this.page+1);
		},
		//跳到最后一页
		go2last : function(){
			this.page!=this.pagenum && this.chgpage(this.pagenum);
		},
		//改变页个数
		chgsize : function(n){
			this.size = isNaN(n) ? this.num : n;;
			this.page = 1;
			this.cb();
		},
		//改变页数
		chgpage : function(n){
			this.page = n;
			this.cb();
		},
		//根据记录数更新
		up : function(num){
			this.num = num;
			this.pagenum = Math.ceil(num/this.size);
			this.fo.num.html(this.num);
			this.fo.pagenum.html(this.pagenum);
			this.fo.page.html(this.page);
			this.fo.size.val(this.size);
			return this;
		},
		inihtm :function(box){
			var html = '总计  <b></b> 个记录分为 <b></b> 页当前第 <b></b> 页，每页 <input size="3" type="text"> <button class="btn">set</button> <button class="btn">showall</button> <a href="javascript:void(0);">第一页</a> <a href="javascript:void(0);">上一页</a> <a href="javascript:void(0);">下一页</a> <a href="javascript:void(0);">最末页</a> <input size="3" id="pageIdx" value="" type="text"> <button class="btn">go</button>';
			box.html(html);
		},
		//检查页个数
		chksize : function(){
			var obj = this.fo.size.node;
			var n = obj.value;
			if(n==""){
				alert("请输入每页显示的个数");
				obj.focus();
				return;
			}
			n = +n;
			if(n<1||n>this.maxsize){
				alert("请输入1~"+this.maxsize+"之间的数字");
				obj.focus();
				return;
			}else if(n==this.size){
				alert("输入的个数不能与当前的每页个数相同");
				obj.focus();
				return;
			}
			this.chgsize(n);
		},	
		//检查页数
		chkpage : function(){
			var obj = this.fo.pageIdx.node;
			var n = obj.value;
			if(n==""){
				alert("请输入页数");
				obj.focus();
				return;
			}
			n = +n;
			if(n<1){
				alert("请输入正确的页数");
				obj.focus();
				return;
			}else if(n>this.pagenum){
				alert("输入的页数不能大于当前总页数");
				obj.focus();
				return;
			}else if(n==this.page){
				alert("输入的页数不能与当前页数相同");
				obj.focus();
				return;
			}		
			this.chgpage(n);
		}
	});
}($1stjs);


//树类
~function(F){
	F.tree = F.Class({
		//初始化 
		init : function (root, data, settings){
			var cls = "firstjs_tree";
			this.img = {};
			var css = [];
			css.push(".firstjs_tree{padding:0px; margin:0px; font-size:12px;}");
			css.push(".firstjs_tree img{vertical-align:top; width:18px; height:18px;}");
			css.push(".firstjs_tree ul{padding:0px; margin:0px; line-height:18px;}");
			css.push(".firstjs_tree li{padding:0px; list-style-type:none; margin-left:18px; clear:both;}");			
			css.push(".firstjs_tree div{height:18px; line-height:18px;}");
			css.push(".firstjs_tree .title div{float:left;}");
			css.push(".firstjs_tree .content:after{content: \".\";display: block;height: 0;clear: both;visibility: hidden;}");
			css.push(".firstjs_tree .content{*zoom:1;}");			
			css.push(".firstjs_tree .icon{width:18px; height:18px;}");
			
			("folder_close,folder_open,plus_top,plus_middle,plus_bottom,minus_top,minus_middle,minus_bottom,"+
			"line_connect,elbow_middle,elbow_bottom,page,empty").replace(/\w+/g, F.proxy(this, function(v){
				this.img[v] = F.data("img/tree/"+v+".gif");
				css.push(F.mix(".$2 .$1{background:url($0) no-repeat 0 0; width:18px; height:18px;}",F.data("img/tree/"+v+".gif"),v,cls));
			}));
			
			F.css(css);
			this.root = F(root).cls(cls);
			this.curNode = null;			
			
			//设置参数
			settings = settings || {};
			this.opened = !!settings.opened;
			this.itemIcon = settings.itemIcon || this.img.page;
			this.itemClick = settings.itemClick;
			this.dirClick = settings.dirClick;
			this.level = isNaN(settings.level) ? 1 : settings.level;
			this.target = settings.target || "_blank";
			//this.open(this.level);	
			
			//设置显示名称和提示字段
			this.items = settings.items || "items";
			this.catekey = settings.catekey || settings.key || "key";
			this.itemkey = settings.itemkey || settings.key || "key";
			this.catedes = settings.catedes || settings.des || "des";
			this.itemdes = settings.itemdes || settings.des || "des";
			
			this.id = settings.id;
			this.pid = settings.pid || "pid";

			F.isstr(data) ? this._showFromFile(data) : this._showFromData(data);
			return this;
		},
		//打开状态
		open : function (obj, a){
			obj = obj.child(a.shift(),0);
			obj.next().css("display")=="none" && obj.fire();
			a.length>0 && this.open(obj.next(), a);
			return this;
		},		
		//从文件读取数据
		_showFromFile : function (fileName){
			F.get(fileName).call2json(F.proxy(this._showFromData,this));
		},
		//直接读取数据
		_showFromData : function (data){
			if(this.id){
				data = this.tranData(data);
			}
			this.add(this.root, data);
			var div = this.root.child(0,0);
			div && div.tag=="div" && div.attr("pos","top").first().src(this.img["plus_"+"top"]);
			!this.root.child(1) && div.fire();
			this.onload && this.onload(this);				
		},
		//数据转换
		tranData : function (a){
			var r = [];
			var hash = {};
			var id=this.id, pid=this.pid, items=this.items;
			F.each(a, function(o,i){
				hash[o[id]] = o;
			});
			F.each(a, function(o,i){
				if(hash[o[pid]]){
					if (!hash[o[pid]][items]){
						hash[o[pid]][items] = [];
					}
					hash[o[pid]][items].push(o);
				}else{
					r.push(o);
				}
			});
			return r;
		},	
		//创建文件夹或Item
		add : function (ul, arr){
			F.each(arr, F.proxy(this, this.addItem, ul, arr.length-1));
		},
		//创建文件夹
		addItem : function (ul,lastIdx,o,i){
			var li = ul.append("li");
			var pos = i==lastIdx ? "bottom" : "middle";
			var items = o[this.items];
			if(items){
				var div = li.append("div.title").attr("pos",pos);
				div.click(F.proxy(this,this.toggle,o,div));
				div.append("div.plus_"+pos);
				if(o.icon){
					o.icon = o.icon.split(" ");
					var icon = div.append("div.icon").bgimg(o.icon[0]);
					o.icon.length>1 && icon.css("background-repeat","no-repeat").bgpos(o.icon[1],o.icon[2]);
				}else{
					div.append("div.folder_close");
				}
				div.append("div").html(o[this.catekey]);
				
				var ul = li.append("ul.content").hide();
				pos=="middle" && ul.css("background:url("+this.img.line_connect+") repeat-y;");
				this.add(ul, items);
			}else{
				li.cls("title").append("div.elbow_"+pos);
				if(o.icon){
					o.icon = o.icon.split(" ");
					var icon = li.append("div.icon").bgimg(o.icon[0]);
					o.icon.length>1 && icon.css("background-repeat","no-repeat").bgpos(o.icon[1],o.icon[2]);
				}else{
					li.append("div.page");
				}				
				//li.append("img").src(this.img.page);
				var html = o[this.itemkey];
				if(o.url){
					html = html.link(o.url, o.target||this.target);
				}					
				var text = li.append("div").css("cursor","pointer").html(" " + html);
				o[this.itemdes] && text.attr("title",o[this.itemdes]);
				this.itemClick && li.click(F.proxy(this,this.itemClick,o));
			}
		},
		//显示或隐藏切换
		toggle : function(o, obj){
			obj.next().css("display")=="none" ? this.show(o,obj) : this.hide(o,obj);
		},
		//显示
		show : function(o,obj){
			obj.next().show();
			obj.child(0).cls("minus_"+obj.attr("pos"));
			!o.icon && obj.child(1).cls("folder_open")			
		},
		//隐藏
		hide : function(o,obj){
			obj.next().hide();
			obj.child(0).cls("plus_"+obj.attr("pos"));
			!o.icon && obj.child(1).cls("folder_close");			
		},		
		//获取树节点
		getNode : function(){
			//获取子节点
			var getChild = function(obj, a){
				var nodes = obj.childNodes, k=0;				
				do{
					obj = nodes[k++];
					if(obj.tagName.toLowerCase()=="ul") break;
				}while(obj);
				
				var nodes = obj.childNodes;
				var l = nodes.length;
				var idx = +a.shift();
				var i;
			
				if(idx<0){
					for(i=l-1; i>=0; i--){
						if(nodes[i].nodeType==1&&++idx==0) break;
					}
				}else{
					for(i=0; i<l; i++){
						if(nodes[i].nodeType==1&&--idx<0) break;
					}
				}
				if(i<0||i>=l){
					throw "getNode("+i+") is out range";
				}				
				return a.length>0 ? getChild(nodes[i],a) : F(nodes[i]);
			}
			return this.treeNode(this, getChild(this.root.node, F.map(arguments)));
		},
		//树节点类
		treeNode : F.Class({
			init : function(tree, node){
				this.tree = tree;
				this.node = node;
			},
			//节点改名
			rename : function(name){
				this.node.html(name);
				return this;				
			},
			//添加子节点
			add : function(o){
				this.node.append("li").append("div").html('<img src="/fw4/img/tree/elbow3.gif"><img src="/fw4/img/tree/page.gif"><span style="cursor: pointer;">中国人民</span>').child(2).html(o.key);
				return this;
			},
			//更新节点
			edit : function(text){
				this.node.child(0,2).html(text);
				return this;
			},			
			//删除节点
			del : function(){
				this.node.remove();
				return this;
			}
		})
	});
}($1stjs);


//菜单组件
~function(F){
	F.menu = F.Class({
		init : function(ops, box){
			F().attr("oncontextmenu","return false");
			this.box = box ? F(box) : F().append("ul").border("#ff00ff 1").ps(1).hide();
			this.box.css("position:absolute; border:1px solid #ff00ff; list-style:none; line-height:25px; background-color:#000; color:#fff; width:80px;");
			this.onshow = ops.onshow;
			this.additems(ops.data);
			return this;
		},
		//添加句柄
		addhand : function(obj){
			F(obj).bind("contextmenu",this.show.proxy(this,obj));
			return this;
		},
		//添加菜单项
		additems : function(data){
			F.each(data, F.proxy(this,this.additem));
			return this;
		},
		//添加单个菜单项
		additem : function(ops){
			var html = ops.icon ? F.mix('<img src="$icon" />$key',ops) : ops.key;
			var li = this.box.append("li").bind("click", F.proxy(this,this.hide)).html(html);
			li.css("cursor:pointer; width:100%; height:20px; line-height:20px; margin-left:10px;");
			ops.click && li.bind("click", ops.click);
			return this;
		},
		//显示
		show : function(obj, e){
			this.box.show().pos(e.x, e.y);
			this.onshow && this.onshow(obj);
			return this;
		},
		//隐藏
		hide : function(){
			this.box.hide();
			return this;
		}
	});
}($1stjs);


//选择器
~function(F){
	F.picker = F.Class({
		init : function (ops){
			this.box = ops.init();
			this.box.click(this.setItem,this);
			return this;
		},
		//绑定到控件中
		bind : function (obj){
			obj = F(obj);
			obj.bind("click", F.proxy(this,this.show, obj));
			return this;
		},
		//显示
		showItem : function (e){
			if(e.target.tagName=="TD"){
				var color = e.target.title;
				this.view.bg(color).attr("title",color);
				this.input.val(color);
			}
		},		
		//选中
		setItem : function (e){
			if(e.target.tagName=="TD"||e.target.className=="view"){
				this.binder.val(e.target.title);
				(!this.cb||this.cb(this.binder.node)!==false) && this.hide();
			}
		},
		//显示
		show : function (obj){
			this.binder = obj;
			var o = obj.abspos(1);
			this.box.pos(o.x, o.y+obj.offsetHeight).show();
			this.ifr && this.ifr.show().sync(this.box,1);
		},
		//隐藏
		hide : function (){
			this.ifr && this.ifr.hide();
			this.box.hide();
			return this;
		}
	});
}($1stjs);


//日期选择器
~function(F){
	F.datePicker = F.Class({
		init : function (){
			this.box = F(arguments[0]);
			this.itemclick = new Function();
			if(this.box.tag=="input"){
				this.w = 28;
				this.box = this.getbox();
				this.on("itemclick", this.select);
				F.each(F.map(arguments), F.proxy(this, this.input));
				this.itemclick = this.select;
			}else{
				this.w = 36;
				this.box.cls("cal");
			}
			this.initUI();
			F.get(F.data("data.php?act=getdate")).callback(F.proxy(this.chkday,this));
			return this;
		},			
			
		//设置显示的时间
		chkday : function(sd){
			sd = sd.split("-");
			var d = new Date();		
			var y = [d.getFullYear(), +sd[0]];
			var m = [d.getMonth()+1, +sd[1]];
			var i = +(!(y[0]==y[1]&&m[0]==m[1])&&window.confirm("您的本机时间与北京时间不同,是否设定为北京时间？"));
			this.y = y[i];
			this.m = m[i];
			this.up(0, 0);
		},
		//设置显示的时间
		setday : function(d){	
			this.y = d.getFullYear();
			this.m = d.getMonth() + 1;
			return this.up(0,0);
		},
		//初始化界面
		initUI : function(){
			this.ym(-1,0,"<<").ym(0,-1,"<").ti().ym(0,1,">").ym(1,0,">>");
			this.wk("日").wk("一").wk("二").wk("三").wk("四").wk("五").wk("六");
			this.space = this.box.append("div.space");
			this.days = [];
			var fun = function(d){
				var t = [this.y,this.m,d].join('-');
				if(this.hms){
					var selects = this.hms.tags("select");
					var a = [];
					for(var i=0; i<selects.length; i++){
						a[i] = selects[i].value;	
					}
					t += " " + a.join(":");
				}
				this.itemclick(t);
			};
			for(var i=0; i<31; i++){
				this.days[i] = this.box.append("a").attr("href","javascript:void(0);").html(i+1).click(F.proxy(fun,this,i+1));
			}
			return this;
		},
		//标题HTML
		ti : function(){
			var fo = this.box.append("b.dateCap").html('<span></span>年<span></span>月');
			this.year = fo.child(0);
			this.moon = fo.child(1);
			return this;
		},
		//年月跳转HTML
		ym : function(y, m, bn){
			this.box.append("b.btn").click(F.proxy(this,this.up,y,m)).html(bn);
			return this;
		},
		//星期HTML
		wk : function(s){
			this.box.append("b").html(s);
			return  this;
		},
		//绑定到控件中
		input : function (id){
			var obj = F(id).node;
			obj.onfocus = F.proxy(this,this.show,obj);
			return this;
		},
		//增加事件
		on : function(handler, fun){
			this[handler] = fun;
			return this;
		},
		//更新HTML
		up : function(y,m){
			y += this.y;
			m += this.m;
			m==13 && (m=1,y++) || m==0 && (m=12,y--);
			this.year.html(y);
			this.moon.html(m);
			this.space.css("w", new Date(y,m-1,1).getDay()*this.w);
			var totaldays = new Date(y, m, 0).getDate();
			for(var i=28; i<31; i++){
				this.days[i].node.style.display = i<totaldays ? "block" : "none";
			}
			this.y = y;
			this.m = m;
			return this;
		},	
		//动态添加层
		getbox : function (){
			var myclass = "F_datePicker";
			F.css('\
				.$v{border:1px solid #1F62BE;width:210px;_width:190px;position:absolute;\
					font-family:Arial;background:#F0F9FF;left:-500px;overflow:hidden; }\
				.$v a,\
				.$v b{display:block; float:left;zoom: 1;width:20px;height:16px;line-height:16px;padding:2px;\
					background:#F0F9FF;font-size:12px;text-align:center;color:#333;font-family:Arial;\
					text-decoration:none;margin:0px 2px;\
				}\
				.$v b{background:none;}\
				.$v a:hover{background:#FE8B1A;color:#fff;font-weight:bold}\
				.$v .btn{cursor:pointer;width:18px;}\
				.$v .dateCap{	width:80px;color:#900; }\
				.$v .space{display:block; float:left; zoom:1; margin:0; width:0; height:20px;}\
				.$v .time{display:block; float:left; width:100%; height:30px; line-height:30px; text-align:center;}\
				.$v .time span{margin:0 5px; font-size:12px;}\
			'.replace(/\$v/g,myclass));
			
			if(F.isie6){
				this.ifr = F().append("iframe").css("cssText","position:absolute; display:none; width:0px; height:0px");
			}
			return F().append("div").cls(myclass).attr("title","点击面板空白处关闭").click(function(e){
				(document.all||e.target==this.obj) && this.hide();
			},this).hide();
		},
		//选中
		select : function (d){
			this.input.value = d;
			this.hide();
		},
		//显示
		show : function (obj){
			this.input = obj;
			var o = F(obj).abspos(1);
			this.box.pos(o.x, o.y+obj.offsetHeight).show();
			this.ifr && this.ifr.show().sync(this.box,1);
		},
		//隐藏
		hide : function (){
			this.ifr && this.ifr.hide();
			this.box.hide();
		},
		//格式化时分秒
		format : function (str){
			var o = {};
			str.replace(/./g,function(s){o[s]=1});
			var hops = [], mops = [], sops = [];
			for(var i=0; i<60; i++){
				o.h && i<24 && hops.push('<option>'+i+'</option>');
				o.m && mops.push('<option>'+F.zero(i)+'</option>');
				o.s && sops.push('<option>'+F.zero(i)+'</option>');		  
			}
			hops = o.h ? '<span><select>'+hops.join("")+'</select>时</span>' : '';
			mops = o.m ? '<span><select>'+mops.join("")+'</select>分</span>' : '';	
			sops = o.s ? '<span><select>'+sops.join("")+'</select>秒</span>' : '';
			this.hms = this.box.append("span.time").html(hops+mops+sops);
		}
	});
}($1stjs);


//颜色选择器
~function(F){
	F.colorPicker = F.Class({
		init : function (){
			this.box = this.create().bind("mousemove",F.proxy(this,this.showItem)).click(this.setItem,this);
			this.view = this.box.cls(".view");
			this.input = this.box.cls(".input").bind("keyup", F.proxy(this,this.chkColor));
			F.each(arguments, F.proxy(this, this.bind));
		},
		callback : function(cb){
			this.cb = cb;
			return this;
		},	
		create : function (){//创建所有HTML
			var myclass = "F_colorPicker";
			F.css(F.mix('\
				.$v{width:170px;_width:175px;text-align:center;border:1px solid #666;background:#E7DFE7 url() no-repeat 97% 6%;font-size:12px;position:absolute;display:none;z-index:999}\
				.$v .colorTitle{text-align:left;margin:5px 5px 0 5px;zoom:1}\
				.$v .view{width:70px;height:20px;background:#000;border:1px solid #000;float:left;margin-right:4px;cursor:pointer;}\
				.$v .input{padding:4px 0 0 4px;float:left;width:55px;border:1px solid #7B9EBD;height:16px;}\
				.$v .colorCell{margin:0 auto;padding:5px;clear:both;}\
				.$v .colorTable table{border-collapse:collapse;}\
				.$v .colorTable table td{border:1px solid #000;height:8px;width:8px;overflow:hidden;font-size:1px;cursor:pointer;}\
			',{v:myclass}));
			
			var m = '00,33,66,99,CC,FF'.split(','),a,b,c,d,e,f,x,y,z,
			T=!!document.attachEvent?'&nbsp;':'';//谷歌会撑开表格
			Html=['<div class="colorTitle"><div class="view" title="#000000"></div><input type="text" class="input" value="#000000" maxlength="7" /></div><div class="colorCell"><table cellspacing="0" cellpadding="0" class="colorTable"><tr>'];
			for (x = 0; x < 6; ++x) {//按规律生成颜色单元格
				Html.push('<td><table cellspacing="0" cellpadding="0">');
				for (y = 0,a = m[x] ; y < 6; ++y) {
					Html.push('<tr>');
					for (z = 0,c = m[y]; z < 6; ++z) {
						b = m[z];
						d = z==5&&x!=2&&x!=5?';border-right:none;':'';
						e = y ==5&&x<3?';border-bottom:none':'';
						f='#'+a+b+c;
						Html.push('<td style="background:'+f+d+e+'" title="'+f+'">'+T+'</td>');
					};
					Html.push('</tr>')
				};
				Html.push('</table></td>');
				if(m[x]=='66')Html.push('</tr><tr>')
			};
			return F().append("div").cls(myclass).html(Html);
		},
		//绑定到控件中
		bind : function (obj){
			obj = F(obj);
			obj.bind("focus", F.proxy(this,this.show, obj));
			return this;
		},
		//显示
		showItem : function (e){
			if(e.target.tagName=="TD"){
				var color = e.target.title;
				this.view.bg(color).attr("title",color);
				this.input.val(color);
			}
		},		
		//选中
		setItem : function (e){
			if(e.target.tagName=="TD"||e.target.className=="view"){
				this.binder.val(e.target.title);
				(!this.cb||this.cb(this.binder.node)!==false) && this.hide();
			}
		},
		//输入检查
		chkColor : function(e, binder){
			var key = e.keyCode;
			if(/[\x2E-\xff]/.test(String.fromCharCode(key))){
				binder.val( "#" + binder.val().replace(/#/g,"").replace(/[^\da-f]/ig,'F').toUpperCase() );
			}
			var color = binder.val();
			if(/^#([\da-f]{3}|[\da-f]{6})$/i.test(color)){
				this.view.bg(color).attr("title",color);
				key==13 && this.view.fire();
			}
		},
		//显示
		show : function (obj){
			this.binder = obj;
			var o = obj.abspos(1);
			this.box.pos(o.x, o.y+obj.offsetHeight).show();
			this.ifr && this.ifr.show().sync(this.box,1);
		},
		//隐藏
		hide : function (){
			this.ifr && this.ifr.hide();
			this.box.hide();
			return this;
		}
	});
}($1stjs);


//绘图类
~function(F){
	F.canvas = F.Class({
		init : function(box){
			this.box = F(box||document.body);
			return this;
		},
		//设置参数
		ops : function(fillcolor, strokecolor, strokeweight){
			if(F.isobj(fillcolor)){
				F.merge(this, fillcolor);
			}else{
				this.fillcolor = fillcolor;
				this.strokecolor = strokecolor;
				this.strokeweight = strokeweight;
			}
			return this;
		},
		//位置尺寸大小
		range : function(x,y,w,h){
			this.x = x;
			this.y = y;
			this.w = w;
			this.h = h;
			return this;
		},
		//旋转
		rotate : function(angle){
			this.angle = angle;
			return this;
		},
		//拷贝
		copy : function(obj){
			return F.canvas(obj||this.box).ops(this.fillcolor,this.strokecolor,this.strokeweight).range(this.x,this.y,this.w,this.h);
		},	
		//圆
		circle : function(x,y,r){
			this.shape = "circle";
			this.chkCanvas("v:oval");
			if(F.iscanvas){
				switch(arguments.length){
					case 0 : this.ctx.arc(this.w/2, this.h/2, Math.min(this.w,this.h)/2,0, Math.PI*2, false); break;
					case 1 : this.ctx.arc(this.w/2, this.h/2, x, 0, Math.PI*2, false); break;
					case 3 : this.ctx.arc(x, y, r, 0, Math.PI*2, false); break;
				}
			}
			return this;
		},
		//矩形
		rect : function(x1,y1,x2,y2){
			if(arguments.length>0&&F.isobj(arguments[0])){
				return this.rect.apply(this, arguments[0]);	
			}
			this.shape = "rect";
			this.chkCanvas("v:rect");
			if(F.iscanvas){
				switch(arguments.length){
					case 0 : this.ctx.rect(0,0,this.w,this.h); break;
					case 2 : this.ctx.rect(0,0,x1,y1); break;
					case 4 : this.ctx.rect(x1,y1,x2,y2); break;
				}
			}
			return this;
		},
		//多边型
		polygon : function(){
			if(arguments.length>0&&F.isobj(arguments[0])){
				return this.polygon.apply(this, arguments[0]);	
			}
			this.shape = "polygon";
			this.chkCanvas("v:shape");
			if(F.iscanvas){
				this.ctx.beginPath();
				var a = arguments, l = a.length;
				this.ctx.moveTo(a[0], a[1]);
				for(var i=2; i<l; i+=2){
					this.ctx.lineTo(a[i], a[i+1]);
				}
				this.ctx.closePath();
			}else{
				var a = F.map(arguments);
				this.canvas.attr({path:"m"+a.splice(0,2).join(",")+"l"+a.join(",")+"xe",coordsize:this.w+","+this.h});	
			}
			return this;
		},
		//线条
		line : function(x1,y1,x2,y2,lineType){
			this.shape = "line";
			this.lineType = lineType || 0;
			this.chkCanvas("v:shape");
			if(F.iscanvas){
				this.ctx.moveTo(x1, y1);
				if(this.lineType==1){
					this.ctx.lineTo(x1, y2);
				}else if(this.lineType==2){
					this.ctx.lineTo(x2, y1);
				}
				this.ctx.lineTo(x2, y2);
				this.ctx.stroke();
			}else{
				var wh = {width:Math.abs(x2-x1),height:Math.abs(y2-y1)}, pos;
				if(this.lineType==0){
					pos = [x2-x1, y2-y1];
				}else if(this.lineType==1){
					pos = [0, y2-y1, x2-x1, y2-y1];
				}else if(this.lineType==2){
					pos = [x2-x1 ,0, x2-x1, y2-y1];
				}
				this.canvas.css(wh).attr({path:"m0,0l"+pos.join(",")+"e",filled:"f",coordsize:wh.width+","+wh.height}).pos(x1,y1,1);
			}
			return this;
		},
		//检查画布
		chkCanvas : function(tag){
			if(!this.canvas){
				if(F.iscanvas){
					this.canvas = this.box.append("canvas").ps().pos(this.x,this.y).attr({width:this.w,height:this.h});
					this.ctx = this.canvas.node.getContext("2d");
					this.ctx.fillStyle = this.fillcolor;
					this.ctx.strokeStyle = this.strokecolor;				
					this.ctx.lineWidth = this.strokeweight;				
					this.angle && (this.ctx.translate(15,15),this.ctx.rotate(this.angle*Math.PI/180));
				}else{
					var ops = F.clone(this,"fillcolor","strokecolor","strokeweight");				
					this.canvas = this.box.append(tag).rect(this.x,this.y,this.w,this.h,1).attr(ops);
				}
			}
			//alert([this.x,this.y,this.w,this.h]);
			F.iscanvas && this.ctx.clearRect(this.x,this.y,this.w,this.h);
		},
		//画笔
		stroke : function(){
			F.iscanvas && this.ctx.stroke();
			return this;
		},
		//填充
		fill : function(){
			F.iscanvas && this.ctx.fill();
			return this;
		},
		//填充文字
		text : function(txt){
			F.iscanvas && this.ctx.fillText(txt, 20, 40);
			return this;
		}
	});
}($1stjs);